Question: Write a java program for below instruction *Simple Vehicle Simulator* 1) Uses a Vehicle class that defines a velocity, position & direction as private hidden

Write a java program for below instruction

*Simple Vehicle Simulator* 1) Uses a Vehicle class that defines a velocity, position & direction as private hidden data. 2) Allow the simulator to create vehicle object at the specific location with velocities in specific directions. The simulator an get the velocity, direction & position. 3) Allows changing velocity by specifying acceleration (positive and negative)time. 4) Allows changing the direction by specifying a value in degrees 5) Allows display of where the vehicle would be after 't' time unit given current velocity position & direction. 6) Allow change of position of the vehicle based on current velocity, position & direction.

*Use below code as template*

public class Vehicle {

// should be private

private double velocity;

private double x;

private double y;

private double direction;

public Vehicle(double v, double x, double y, double d) {

// d is given as degrees, you should store it internally as radians

}

public double getVelocity() {

}

public double getDirection() {

// return direction in degrees not radians

}

public double [] getPosition() {

// return an array of doubles as the x, y pair

}

public void changeVelocity(double accelartion, int time) {

// acceleration can be positive or negative

// velocity is changed based on duration of acceleration

}

public double [] showNewPosition(int t) {

// return the new x,y pair based on travelling for time t

// based on current velocity, direction and position

// does not change the vehicle's position

}

public void changePosition(int t) {

// changes the x,y pair based on travelling for time t

// based on current velocity, direction and position.

}

}

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 Databases Questions!