Question: JAVA QUESTION: There are 2 parts to the question, so please submit your answer as two seperate parts. THIS IS PART 2 Part 1 You

JAVA QUESTION: There are 2 parts to the question, so please submit your answer as two seperate parts.

JAVA QUESTION: There are 2 parts to the question, so please submit

your answer as two seperate parts. THIS IS PART 2 Part 1

You will create two classes Car and RaceLane. Your main method will

THIS IS PART 2

go in RaceLane.1 1. Define a class Car. All of the below

properties/methods should be non static. A Car should have five private properties:

a String for the model of the car (e.g. Toyota Camry), an

int location, an int currentSpeed, a boolean movingForward, and an int maxSpeed.

The idea is that the location data member stores where on a

Part 1 You will create two classes Car and RaceLane. Your main method will go in RaceLane.1 1. Define a class Car. All of the below properties/methods should be non static. A Car should have five private properties: a String for the model of the car (e.g. Toyota Camry), an int location, an int currentSpeed, a boolean movingForward, and an int maxSpeed. The idea is that the location data member stores where on a number line the Car is. Make sure the number entered is 2 0 a. b. A default constructor A constructor that takes as input three things: A String for the model, an int maxSpeed, and an int for an initial location. It should set the model of the Car, the max speed, and initial location appropriately based on the input. The constructor should make it so that the movingForward property should always be initially set to be true. The currentSpeed should always be initially set to be 0. c. Write three methods called getModel(),getDirection(), and getLocation() that let you retrieve the model, movingForward, and location properties respectively. d. Write a method go() which sets the currentSpeed of the Car object to be the object's maxSpeed. e. f. Write a method stop() which sets the currentSpeed of the Car object to be 0. Write a method turnAround() which changes the boolean variable movingForward to be the opposite of what it was before. That is, if it was true before, it should be false now. If it was false before, it should now be true. g

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!