Question: You are requested to create a java class named Honda Civic, which is one of the most demanded cars in the Canadian market. The

You are requested to create a java class named Honda Civic, which is one of the most demanded cars in the Canadian market. The Honda Civic class will have at least the following attributes: numberOfDoors(int): the number of doors, make sure it's 3 or 5. color(String): 6 possible case-insensitive String values for color are: silver, grey, black, white, blue, and red. price(double): The price of cars is subject to change, but you must ensure that it is between $20,000 and $40,000. The price of the car is common to all the Honda Civic objects created. If the price of a car changes, then the change applies automatically to all car objects. Print an appropriate error message for any invalid field. The class should have methods to set and get the attributes as follow: getNumberDoors() setNumberDoors(int) getPrice() setPrice(double) getColor() setColor(String) The class should also include a toString() method to return all information of a Honda Civic. For example the toString() method should return a String in the following format: Number of doors: 3, color: red, price: 25000.0 Number of doors: 5, color: grey, price: 22000.0 Number of doors: 3, color: red, price: 22000.0
Step by Step Solution
3.44 Rating (144 Votes )
There are 3 Steps involved in it
Attributes for the HondaCivic class numberOfDoors int Represents the number of doors Ens... View full answer
Get step-by-step solutions from verified subject matter experts
