Help with Pong collision checks

Hello, i am trying to make a pong-like game for a project in my java class, and things have been going fine so far, except… The collision checks are not working for the paddle located on the left… This is likely a problem with our collide check method, but… From looking at the method itself, it seems like it would work fine.

Here is the code so far, if anyone could offer a suggestion, that would be great


import java.applet.*;
import java.awt.*;
import java.util.*;
import java.awt.event.*;

public class TestApplet extends Applet implements Runnable
{    
    //Paddle dimensions
    int PaddleHeight = 50;
    int PaddleWidth = 10;
    
    //Other variables
    boolean isStop = true;
    int[] theKeys = new int[256]; //Array with one element representing each key
    Random Rand = new Random();
    int bounces = 0;
    boolean isAI2 = false;
    boolean isAI1 = false;
    ArrayList <Ball> TheBalls  = new ArrayList <Ball>();
    ArrayList <Paddle> ThePaddles = new ArrayList <Paddle>();
    
    //Player scores
    int Score1 = 0;
    int Score2 = 0;
    
    private Image dblimage;
    private Graphics dbg;
    
    public void init()
    {
        //Set Background color to black
        setBackground(Color.black);
    }
    
    public void start()
    {
        //Define new thread
        Thread th = new Thread(this);
        //Start the new thread 
        th.start();
        for(int z=0; z<256; z++)
            theKeys[z] = 0; //Set all keys to default position (released)
        enableEvents(AWTEvent.KEY_EVENT_MASK);
        ThePaddles.add(new Paddle(true, PaddleHeight, PaddleWidth, 10, this.getWidth(), this.getHeight(), 'w', 's'));
        ThePaddles.add(new Paddle(false, PaddleHeight, PaddleWidth, 10, this.getWidth(), this.getHeight(), '8', '5'));
        TheBalls.add(new Ball(this.getHeight(), this.getWidth()));
        TheBalls.get(0).AddPaddle(ThePaddles.get(0));
        TheBalls.get(0).AddPaddle(ThePaddles.get(1));
        
    }

    public void run ()
    {
        //Minimize thread priority
        Thread.currentThread().setPriority(Thread.MIN_PRIORITY);

        while (true)
        {            
            for(int i=0; i<ThePaddles.size(); i++)
            {
                if(isKeyPress(87))
                {
                    ThePaddles.get(i).Move(1);
                }
                else if(isKeyPress(83))
                {
                    ThePaddles.get(i).Move(-1);
                }
            }  
            if(isKeyPress(32))
            {
                for(int x=0; x < TheBalls.size(); x++)
                    TheBalls.get(x).Start();
                isStop = false;
                bounces = 0;
            }
            
            for(int i=0; i<TheBalls.size(); i++)
            {
                TheBalls.get(i).Move();
                
                String scored = TheBalls.get(i).IsScore();
                if(scored == "Player 1")
                {
                     Score1++;
                     break;
                }
                else if(scored == "Player 2")
                {
                    Score2++;
                    break;
                }
            }
            repaint();      
            try
            {
                Thread.sleep (20);
            }
            catch (InterruptedException ex)
            {
                // do nothing
            }
            

            Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
        }
    }
    public void paint(Graphics g)
    {
        //set color
        g.setColor(Color.green);
        
        for(Ball temp : TheBalls)
        {
            int[] tempfo = temp.BallInfo();
            g.fillOval(tempfo[0], tempfo[1], tempfo[2], tempfo[3]);
        }
        
        
        for(Paddle temp: ThePaddles) 
        {
            int[] PadTemp = temp.PaddleData();
            g.fillRect(PadTemp[0], PadTemp[1], PadTemp[2], PadTemp[3]);
          
        }
        //paint player 1 score
        g.drawString("Player 1 score: "+Score1, 10, 50);
        
        //paint player 2 score
        g.drawString("Player 2 score: "+Score2, 400, 50);
        
        //paint current bounce count
        g.drawString("Bounces: "+bounces, 250, 50);
        
        g.drawString(""+ThePaddles.get(0).GetUp(), 100, 100);
        g.drawString(""+ThePaddles.get(0).GetDown(), 100, 400);
        g.drawString(""+ThePaddles.get(1).GetUp(), 200, 100);
        g.drawString(""+ThePaddles.get(1).GetDown(), 200, 400);
        g.drawString(""+TheBalls.get(0).Collide(), 250, 250);
        g.drawLine(ThePaddles.get(0).getX(), ThePaddles.get(0).GetTop(), ThePaddles.get(0).getX()-500, ThePaddles.get(0).GetTop());
        

    }
    
    public void update (Graphics g)
    {

      // initialize buffer
      if (dblimage == null)
      {
            dblimage = createImage (this.getSize().width, this.getSize().height);
            dbg = dblimage.getGraphics ();
      }

      // clear screen in background
      dbg.setColor (getBackground ());
      dbg.fillRect (0, 0, this.getSize().width, this.getSize().height);

      // draw elements in background
      dbg.setColor (getForeground());
      paint (dbg);

      // draw image on the screen
      g.drawImage (dblimage, 0, 0, this);
    }
 
    public void processKeyEvent(KeyEvent ev)
    {
        int keycode = (ev.getKeyCode()&0xff);
        if (ev.getID() == KeyEvent.KEY_PRESSED)
        {
            theKeys[keycode] = 1; //1 Represents key is pressed
        }
        else if (ev.getID() == KeyEvent.KEY_RELEASED)
        {
            theKeys[keycode] = 0; //0 Represents key is not pressed
        }
        repaint();
    }
    
    //Checks if a given key is pressed
    public boolean isKeyPress(int theKey)
    {
        return (theKeys[theKey] != 0);
    }
    
    //Checks if a given key is released
    public boolean isKeyRel(int theKey)
    {
        return(theKeys[theKey] == 0);
    }
 } 


Sorry for the double post, but not enough room for all of the code


class Paddle
{
     
     private int 
        XPos,
        YPos,
        Width,
        Height,
        Speed,
        AppletHeight,
        AppletWidth,
        Down,
        Up;
      boolean
        LeftSide;
        
     public Paddle(boolean LeftSide, int Height, int Width, int Speed, int AppletWidth, int AppletHeight, char Up, char Down)
     {
         this.AppletHeight = AppletHeight;
         this.AppletWidth = AppletWidth;
         YPos = AppletHeight/2;
         this.Height = Height;
         this.Width = Width;
         this.Speed = Speed;
         this.LeftSide = LeftSide;
         if(LeftSide)
            this.XPos = 25;
         else
            this.XPos = AppletWidth-25;         
         Character UpChar = new Character(Up);
         Character DownChar = new Character(Down);
         this.Up = UpChar.charValue();
         this.Down = DownChar.charValue();
     }
     
    public void Move(int x)
    {
        if(x > 0)
        {
            YPos -= Speed;
        }
        else
           YPos += Speed;
    }
    
    public boolean IsLeft()
    {
        return LeftSide;
    }
        
    
    public int GetTop()
    {
        return YPos - Height/2;
    }
    
    public int GetBottom()
    {
        return YPos + Height/2;
    }
    
    public int GetUp()
    {
        return Up;
    }
    
    public int GetDown()
    {
        return Down;
    }
    
    public int getX()
    {
        return XPos;
    }
    
    public int getY()
    {
        return YPos;
    }
    
    public int GetHeight()
    {
        return Height;
    }
    
    public int GetWidth()
    {
        return Width;
    }
     
    public int[] PaddleData()
    {
        if(LeftSide)
            return new int[]{XPos, YPos-Height/2, Width, Height};
        return new int[]{XPos, YPos-Height/2, Width, Height};
    }
}


class Ball
{
    private int
        XPos,
        XSpeed,
        YPos,
        YSpeed,
        Radius,
        MaxSpeed,
        Height,
        Width;
        
    private boolean
        IsStill; 
        
    private ArrayList <Paddle> 
        ThePaddles=new ArrayList <Paddle>();
     
    private Random Rand=new Random();
     
    public Ball(int Width, int Height)
    {
         this.ThePaddles=ThePaddles;
         this.Height=Height;
         this.Width=Width;
         XPos=Width/2;
         YPos=Height/2;
         IsStill=true;
         MaxSpeed=9;
         Radius=10;
         ChangeAngle();
    }   
    
    public void AddPaddle(Paddle temp)
    {
       ThePaddles.add(temp);
    }
    
    public int[] BallInfo()
    {
        return new int[]{XPos-Radius, YPos-Radius, 2*Radius, 2*Radius};        
    }
    
    public void Start()
    {
        IsStill = false;
    }
    
    public int getX()
    {
        return XPos;
    }
    
    public int getY()
    {
        return YPos;
    }
    
    public int getRad()
    {
        return Radius;
    }
    
    public void RevX()
    {
        XSpeed *= -1;
    }
    
    public int getXSp()
    {
        return XSpeed;
    }
    
    public int getYSp()
    {
        return YSpeed;
    }
   
    
    public boolean isNeg()
    {
        if(XSpeed < 0)
            return true;
        return false;
    }
              
    //Generates a random trajectory for the ball
    public void ChangeAngle()
    {
        int Num, Opp;
        
        Num= Rand.nextInt(MaxSpeed)+1;
        Opp = MaxSpeed-Num;
        
        XSpeed = ((XSpeed>0)?1:-1)*Num;
        YSpeed = ((Rand.nextInt(2)==0)?1:-1)*Opp;    
    }
    
/*    public boolean Collide()
    {    
        boolean collid=false;
        for(Paddle i: ThePaddles)
        {            
            if(YPos >= i.GetTop() && YPos <= i.GetBottom())
            {
                if(i.LeftSide)
                    collid = (((XPos - Radius) <= (i.getX() + i.GetWidth())));
                if(!collid)
                    collid = (((XPos + Radius) >= (i.getX() - i.GetWidth())));                        
            }
        }
        if(!collid)
            collid = ((YPos<=0 && YSpeed < 0) || (YPos>=Height && YSpeed > 0)); 
        return collid;
    }
  */
    

    public boolean Collide()
    {    
        boolean collid=false;
        Paddle i = ThePaddles.get(0);
        if(YPos >= i.GetTop() && YPos <= i.GetBottom())
        {
            //if(i.getX() < Width/2)
                collid = (((XPos - Radius) <= (i.getX() + i.GetWidth())));
            //else if(i.getX() > Width/2)
              //  collid = (((XPos + Radius) >= (i.getX())));
        }
        i = ThePaddles.get(1);
        if(YPos >= i.GetTop() && YPos <= i.GetBottom())
        {
           // if(i.getX() < Width/2)
             //   collid = (((XPos - Radius) <= (i.getX() + i.GetWidth())));
            //else if(i.getX() > Width/2)
                collid = (((XPos + Radius) >= (i.getX())));
        }
        if(!collid)
            collid = ((YPos<=0 && YSpeed < 0) || (YPos>=Height && YSpeed > 0)); 
        return collid;
    }


    public String IsScore()
    {
        Random rand = new Random();
        
        if(XPos >= Width)
        {
            XPos = Width/2;
            YPos = Height/2; 
            if(Rand.nextInt(2) == 1)
                RevX();
            ChangeAngle();
            IsStill = true;
            return "Player 1";
        }
        if(XPos <= 0)
        {
            XPos = Width/2;
            YPos = Height/2;
            if(Rand.nextInt(2) == 1)
                RevX();
            ChangeAngle();
            IsStill = true;
            return "Player 2";
        }
        return "";
    }
    
    public void Move()
    {
        boolean temp = false;
        
        for(int i=0; i<=Math.abs(XSpeed); i++)
        {
            if((Collide()) && !temp)
            {
                RevX();
                ChangeAngle();
                temp = true;
                XPos = ((XSpeed>0)?XPos+5:XPos-5);
                break;
            }
            XPos = ((XSpeed>0)?XPos+1:XPos-1);
        }
        temp = false;
        for(int i=0; i<=Math.abs(YSpeed); i++)
        {
            if((Collide()) && !temp)
            {
                YSpeed *= -1;
                temp = true;
                break;
            }
            YPos = ((YSpeed>0)?YPos+1:YPos-1);
        }
    }
}   

delete the second post, edit the first and clear it, put only collision method and explain variable names

You dont expect anyone to read and understand all this to point out the line where the problem is?

Find the problem, for example to some output and pin down the lines or function where it fails.
Then post just this. Please.

-JAW