36.8k views
0 votes
3A - Create a class named Automobile. Define the automobile with fields for the automobile’s Manufacturer, Model, Color and Price. You need to create the accessor/mutator (get and set) methods for all fields. Also create a default constructor that sets the values to TATA, PUNCH, BLACK, $8,000. Write another parameterized constructor that will CALCULATE the price based on values passed to it. The base price is $8,000. Add $1,000 to the base price for a red automobile, add $3,000 for a gold automobile and add $5,000 for a Platinum automobile. Also, add $2,000 for a BMW manufactured automobile, and $10,000 for a ROLLS ROYCE. Therefore: a Platinum BMW costs ($8000 + $5000 + $2000) while a Red Punch costs ($8000 + $1000 + $0). Write a method to display ALL FOUR fields nicely on the screen. Call your code "Automobile.java". 3B - Create a child class named Turbo Automobile that extends Automobile and includes three additional fields: one for the number that is the maximum speed, one that is a number to represent maximum occupants and another Boolean field for Manual Transmission. If it is a Manual Transmission charge an additional $500 for clutch assembly. Also add an emissions TURBO fee of 10% to the total price for all objects of Turbo Automobile. Be sure to write a method to display all seven fields nicely on the screen. Call your code "TurboAutomobile.java". 3C - Create a MAIN CLASS / application that will demonstrate and display the objects. You MUST create two objects of "Automobile" and two objects of "Turbo Automobile" and display ALL THEIR DATA FIELDS. Call your code "DemoAutos.java". Do not put your code in the editor below. SUBMIT YOUR JAVA OR TXT FILE in the Additional Content section BELOW

User Razinar
by
7.5k points

1 Answer

4 votes

Final answer:

To complete the task, you need to create the Automobile class with fields and methods as described. Then, create the Turbo Automobile class, which extends the Automobile class and adds additional fields and methods. Finally, create the Main Class to demonstrate and display the objects.

Step-by-step explanation:

Automobile Class-

To create the Automobile class, you will need to define four fields: Manufacturer, Model, Color, and Price. Additionally, you need to create accessor and mutator methods for all the fields. The class should also have a default constructor that sets the values to TATA, PUNCH, BLACK, and $8,000. Another parameterized constructor should calculate the price based on the values passed to it, adding different amounts depending on the color and manufacturer. Finally, you should implement a method to display all four fields.

Turbo Automobile Class-

The Turbo Automobile class is a child class of the Automobile class and includes three additional fields: Maximum Speed, Maximum Occupants, and Manual Transmission (as a Boolean field). The class should also have a method to calculate the total price, considering an additional fee for Manual Transmission and an emissions TURBO fee of 10%. Finally, implement a method to display all seven fields nicely on the screen.

Main Class-

The Main Class should demonstrate and display the objects. Create two objects of the Automobile class and two objects of the Turbo Automobile class. Display all their data fields.

User Tyrell
by
8.0k points