Follow these steps:
- Download the attached BlueJ project file, Collision.zip to your java folder. Double click on it.
- Open the folder and double-click the BlueJ package icon.
- Replace “_YI” suffix with your initials in all the files that use it.
- Study the code for the Ball_YI, BallDriver_YI, and CollidingBall_YI classes.
- Modify the Ball_YI class as follows:
— a. When any ball collides with another, the ball changes direction. Their behavior after the collision is up to you but it has to be noticeable. There are two types of collisions, elastic and inelastic. It is also up to you to choose the type.
— b. When any ball collides with each other, the ball changes to a random color and stays that color until it collides again.
— c. When any ball collides with the walls, the ball changes to a random color. NOTE: It is ok if all the balls change color at the same time.
Submission: - A short QuickTime video.
- Attach Ball_YI, and CollidingBall_YI classes.
Collision Detection:
These diagram should help you with the calculations for the conditions you need to implement to capture the the balls within a “d” distance of each other:
More Hints: look at the problem from the cartessian plane perspective: