Question: This lab will involve the following new features: - Inheritance High level description: Make a java application that creates vehicle ojects and is able to

This lab will involve the following new features:

- Inheritance

High level description:

Make a java application that creates vehicle ojects and is able to start

and stop them based on user requests.

---------------

---------------

--- DETAILS ---

---------------

---------------

1. 5 classes required.

- When you start your project, you can make your main method class

called "Vehicle_Test".

- As the last step of these instructions, it will say what to put in

the main method.

- Make a MotorVehicle class.

- Make a Motorcycle and a Car class that inherit from the MotorVehicle

class.

- Declare one instance variable in each of these classes that is

unique to the type.

- For example, you could put a "doorCount" int variable in the Car

class and a "windshield" boolean variable into the Motorcycle

class.

- Declare at least two instance variables in the parent MoterVehicle

class that each child class inherits.

- One instance variable must be a boolean that is called "running";

- The other instance variable is up to you... "color", "make", etc.

- In the Motorcycle and Car classes, Make two methods in each: start

and stop methods.

- The start and stop methods will first change the "running"

variable.

- In the start method, set the running variable to true.

- In the stop method, set the running variable to false.

- The start and stop methods will then print to the screen:

- The class's two inherited instance variable values.

- The specific class's instance variable value (such as "doorCount"

for the Car class).

- What type of vehicle it is (Motorcycle or Car).

- Whether it's been stopped or started.

- Reminder: Motorcycle and Car classes will both inherit from a parent.

- Make a VehicleManager class.

- Two instance variables that are arrays, one of Car type and one of

Motorcycle type.

- A "run" method that does the following:

- Instantiates three objects of Car type and three of Motorcycle

type.

- Sets the "running" variable on each to false.

- Fills the other instance variables on each object directly in

code with any value you wish.

- So if you had "color" as a variable of String type in

MotorVehicle, set one to "red", one to "green", etc.

- Put all the objects into the two arrays mentioned above.

- (car objects in cars array, motorcycle objects in motorcycles

array)

- Then displays a series of things to the user with the following

flow:

- 1. First a menu for choosing which car to START:

- Lists the cars with numbers and asks which one to start.

- Use 1 to 3 as menu item numbers instead of 0 to 2.

- When item # chosen, then the start method for that object is

called.

- The number they enter has to be adjusted for the correct

array index obviously.

- 2. Second is the menu for which motorcycle to START:

- Same as 1. above except now for the motorcycle array.

- 3. Third is the menu for which car to STOP:

- Same as the ones above except now the stop method is being

called instead of start.

- 4. Fourth is the menu for which motorcycle to STOP.

- Same as above, but now for motorcycle.

- 5. Display all 6 vehicles status on whether they're running or

not.

- In your Vehicle_Test class that has the main method:

- Instantiate an instance of VehicleManager and calls its

"run" method.

Use IntelliJ please and if need creatre new class file please make a mark.

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!