Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Below is the implementation of the HondaCivic class in Java according ... 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

Step: 3

blur-text-image

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

Managing Business Ethics Making Ethical Decisions

Authors: Alfred A. Marcus, Timothy J. Hargrave

1st Edition

1506388590, 978-1506388595

More Books

Students also viewed these Programming questions