Answered step by step
Verified Expert Solution
Question
1 Approved Answer
-size: double Ball + getSize() double + setSize (s: double) + roll () + bounce (numberOfBounces : int) Description: Create a project called LabBall
-size: double Ball + getSize() double + setSize (s: double) + roll () + bounce (numberOfBounces : int) Description: Create a project called LabBall Add 2 files: Ball.java and BallApp.java (BallApp.java includes the main method ) Once you added the appropriate class headers with empty class body and the empty main method compile and run to ensure that the project is set up properly In Ball.java implement class Ball as described above Implement input validation in the setter. Only allow the size of the ball to be >= 0. If the size passed as an argument is negative, leave the field value unchanged (no action required). " 0 Method roll should print "rolling .. Method bounce should print how often the ball is bouncing depending on the parameter value g. "bouncing 3 times or bouncing 1 times" (yes, there is a grammar mistake. No need to worry about it. If you like a challenge though, feel free to remove the extra 's') Hint: this is a fill-in-the-blank situation and you can use printf to display the desired output In BallApp.java in the main method do the following O O Create an instance of Ball called myBall. It should have size 5 Print the size of the ball (use a label) Make the ball roll Make the ball bounce 14 times Increase the size of the ball to size 7 Print the size of the ball (a second time) Notice: The size is printed twice. First we used the label "Ball with size " and then we used just "size: ". Labels are used to make the output clear and easy to read and understand. In the first line we included the information that the size we are displaying is the size of a ball. In the last line this information was no longer helpful and thus dropped. Expected Output: Ball with size 5 rolling... bouncing 14 times size: 7
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started