Create a superclass called Car. The Car class has the following fields and methods. int speed; float regular Price; str color; float get Sale Price();
Create a superclass called Car. The Car class has the following fields and methods. int speed; float regular Price; str color; float get Sale Price();
2. Create a subclass of Car class and name it as Truck. The Truck class has the following fields and methods. int weight; float get Sale Price(); # If weight>2000, 10% discount. Otherwise, a 20% discount.
3. Create a subclass of Car class and name it as Ford. The Ford-class has the following fields and methods int year; int manufacturer Discount; float get sale price(); # From the sale price computed from Car class, subtract the manufacturer discount.
4. Create a subclass of Car class and name it as Sedan. The Sedan class has the following fields and methods. int length; float get sale price(); # If length > 20 feet , 5% discount, Otherwise, 10% discount.
5. Create My Own Auto Shop class which contains a main() method. Perform the following within the main() method.
a. Create an instance of Sedan class and initialize all the fields with appropriate values. Use the super(...) method in the constructor for initializing the fields of the superclass.
b. Create two instances of the Ford-class and initialize all the fields with appropriate values. Use the super(...) method in the constructor for initializing the fields of the superclass.
c. Create an instance of Car class and initialize all the fields with appropriate values. Display the sale prices of all instance.
Step by Step Solution
3.28 Rating (154 Votes )
There are 3 Steps involved in it
Step: 1
Please find below the code in java I have added comments in the code for you to understand Car class class Car Car variables int speed float regularPrice String color Car constructor to set speed regu...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