create a java class named HondaCivic, which is one of the most demanded cars in the Canadian
Fantastic news! We've Found the answer you've been seeking!
Question:
create a java class named HondaCivic, which is one of the most demanded cars in the Canadian market.
The HondaCivic 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 HondaCivic 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
Related Book For
Managing Business Ethics Making Ethical Decisions
ISBN: 9781506388595
1st Edition
Authors: Alfred A. Marcus, Timothy J. Hargrave
Posted Date: