can you explain why i should keep this in the ball class? why would it be any different if it was outside of the class?
Definitely. Good question. Inside the class, it allows you to have a ball object Ball myBall = new Ball(x, y, width, height); and be able to refer to that ball's rectangle without needing to know about or deal with any other balls, Rectangle boundary = myBall.getBallBounds();.
If I put it outside the class and I want to know the boundaries of any given ball, I'll need to provide this method with what ball I am talking about (something like Rectangle boundary = getBallBounds(myBall);). It would certainly not be wrong to do it that way. But I've noticed that generally if you're making a method from scratch, you've tended to make it with no parameters. So I was favoring the way your were already writing methods.
And another perk (but not a 'metric' you should be using to make decisions at this point) is if your next game was going to do something different but still be using balls, you could very well have this Ball class in its own file and use it for both this game and the next one. If you have getBallBounds(Ball ball) in this game class, that means if your next game needed that same functionality, you'd have to implement it again. But since it does make good sense that the ball would be able to provide you with its own bounds, having inside the class is logical and makes one less piece of functionality that you'd have to re-implement.
In this code, you call getBallBounds() so it's returning you a Rectangle object but you're not doing anything with it. So you're not using it right now nor are you saving it somewhere (in some variable) so you can pull it back up later to use.im thinking i should put it in the updateGame method and in the if method after the new ball is created every three seconds
...
so maybe something like this?
Your getBallBounds method is looking alright. You did pull up the x and y values from this particular ball. Why did you hardcode the width and height rather than pulling those values from this particular ball as well?