Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For Java, I need to create a MotorVehicle class in Java that has two instance variables that each child class (Motorcycle and Car) will inherit.

For Java, I need to create a MotorVehicle class in Java that has two instance variables that each child class (Motorcycle and Car) will inherit. One instance variable must be a boolean that is called "running" and the other instance variable can be anything like "color", "make", etc.

In the Motorcycle and Car classes, they need to inherit from the MotorVehicle class and each need their own instance variable in 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.

In the Motorcycle and Car classes, make two methods in each: start and stop methods that will first change the "running" variable. In the start method, set the running variable to true and in the stop method, set the running variable to false. Then 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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Privacy In Statistical Databases International Conference Psd 2022 Paris France September 21 23 2022 Proceedings Lncs 13463

Authors: Josep Domingo-Ferrer ,Maryline Laurent

1st Edition

3031139445, 978-3031139444

More Books

Students also viewed these Databases questions