After reading the rest of Chapter 15 and you have practiced running the sample p
ID: 3822383 • Letter: A
Question
After reading the rest of Chapter 15 and you have practiced running the sample programs in the Chapter, analyze the BouncingBallControl program on page 619. You will see that the program uses an extend Class of pane() called BallPane on page 617. This is an example similar to the ClockPane Class that modifies a standard Application Class shown back in Chapter 14 to make a completely different application by mainly extending the Pane Class.
Think about how you could add a filled-in rectangle that the user could move up and down in the BallPane. Then think about how and where you would add the check to change the ball's direction if it hits the rectangle. Could it simply be a reversal of direction or what would you have to do to simulate what really would happen if it hit the rectangle?
I do not need to see a full application. This is not a programming assignment... it is meant to be a thought-provoking set of questions which forces you to really understand how the author has demonstrated how to use animations with JavaFX. Tell us what you would do to implement the above proposed modifications and answer the direction reversal question here.
Explanation / Answer
Simply you can create a rectangle instance that is movable using Rectangle class.Then as the ball collides with rectangle changle ball move direction using moveball function.You just cant reverse the ball direction as what if it strikes from the sides and not from top/bottom, so using the given function you can change its direction