Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started