Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java - manufacturer of type String - model of type String - year of type int The Vehicle class should have a constructor with parameters

Java image text in transcribed
- manufacturer of type String - model of type String - year of type int The Vehicle class should have a constructor with parameters for each field. The constructor should set the value of each of its fields. The Vehicle class should have get and set methods for each field. The get and set methods should not call any other method. The Vehicle class should have a toString() method that returns a String containing the values of each of its fields. The tostring() method should not call any other method. The Vehicle class should contain an abstract method named numberWheels() with return type int. The Vehicle class should not contain any additional fields or methods besides those listed in this paragraph. The Vehicle class should not implement any interfaces. The Vehicle class should not extend any other class. Write a public interface named Measurable. The interface should contain a constant named mileageRate of type double initialized to 1.38. The interface should have one method named getMileage() with return type double. The Measurable interface should not contain any additional methods besides those listed in this paragraph. Write a public class named Car. The Car class should be a child class of the Vehicle class. The Car class should have a field of type int named numberDoors. The Car class should have a constructor with parameters for each of its fields. The Car class constructor should set the values of each its fields. The Car class should have a toString() method that returns a String containing the values of each of its fields. The toString() method should not call any other method other than methods in the parent class. The class has get and set methods for each of its fields. The get and set methods should not call any other method. The Car class should implement the Measurable interface. Write a public class named MotorCycle. The MotorCycle class should be a child class of the Vehicle class. The MotorCycle class should have a field of type int named engineDisplacement. The MotorCycle class should have a constructor with parameters for each of its fields. The MotorCycle class constructor should set the values of each of its fields. The MotorCycle class should have a toString() method that returns a String containing the values of each of its fields. The tostring() method should not call any other method other than methods in the parent class. The class has get and set methods for each of its fields. The get and set methods should not call any other method. The MotorCycle class should implement the Measurable interface. The class should contain no other fields, constructors, or methods other than those listed in this paragraph. Write a public class named TestVehicle with a main() method that creates a single array that contains two different anonymous Car objects and two different anonymous MotorCycle objects. Use a for loop to print the objects in the array, one per line. Inside the for loop, also call the numberWheels( ) and getMileage() method of each object and print the results to the screen. Your code should work correctly for any array containing Car and Motorcycle objects. The class should contain no other fields, constructors, or methods other than those listed in this paragraph

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

Beginning PostgreSQL On The Cloud Simplifying Database As A Service On Cloud Platforms

Authors: Baji Shaik ,Avinash Vallarapu

1st Edition

1484234464, 978-1484234464

More Books

Students also viewed these Databases questions