For this assignment you are going to write a program that simulates what happens when a ball
Fantastic news! We've Found the answer you've been seeking!
Question:
For this assignment you are going to write a program that simulates what happens when a ball is thrown at a particular angle and initial velocity.
You will need to Make a class called Ball that keeps track of the status of the ball at a given time, and updates that status as time passes. In addition you must create a main class called YourlastnameAssign4.java (with your actual last name) that runs the simulation given input from the user.
Your Ball class should have the following private fields, all of which should be doubles:
- hDist - the horizontal distance from the point where the ball was thrown in meters.
- vDist - the vertical distance of the ball from the ground in meters.
- hSpeed - how fast the ball is travelling horizontally in meters per second.
- vSpeed - how fast the ball is travelling vertically in meters per second.
Your Ball class should also have the the following public methods:
public void initialize(double angle, double velocity, double height) - sets up the initial conditions as follows:
- The horizontal distance should be set to 0.
- The vertical distance should be set to height.
- The horizontal speed should be set to velocity multiplied by Math.cos(Math.toRadians(angle)).
- The vertical speed should be set to velocity multiplied by Math.sin(Math.toRadians(angle)).
Related Book For
Posted Date: