Question: Java - write and test a class of models a ball that bounces in a given direction, a ball bounces along the x axis between

Java- write and test a class of models a ball that bounces in a given direction, a ball bounces along the x axis between a wall at 0 and another wall at a
given distance. the move method advances its position by one unit when it reaches either wall it changes
direction.
public class Ball {
//instance variables
/*your code goes here*/
/**constructs a ball at position 0 traveling east. @param rightWall the position if the wall to the right**/
public Ball(int rightWall)
{/*your code goes here*/}
/**moves the ball**/
public void move()
{/*your code goes here*/}
/** gets the current position. @return the current position**/
public int getPosition()
{/*your code goes here*/}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!