subject

Write a class named car that represents a car. your car class should have the followning: 1. instance variablesi. make and model of the carii. color of the cariii. the car's priceiv. the car's mileage (total miles traveled, not miles per gallon)2. two overloaded constructorsi. a constructor that takes no parameters. this constructor should set the mileage to 0 and set some default values (use whatever you want ) for the make, model, color and price. ii. a constructor that allows you to set values for the make, model, color and price. this constructor should also set the mileage to 0.3. methodspublic void setprice(double p)this should update the instance variable for price with the specified value. public void paint(string c)this should "paint " the car by changing the instance variable for color with the specified value. public void displaycarinfo()this should display all available information on the car, including its make, model, coor, price, and mileage. public void travel(double distance)this should display a message saying that the car is traveling for the specified distance. this method should also increase the value of the mileage attribute accordingly. after the car class, write a separate client program containing a main method that does the following actions: 1. create two new car objects: a black porsche cayman s with a price of $ 63,800, and a blue nissan leaf with a price of $ 28,800.2. display information for each object by calling its displaycarinfo method.3. paint the cayman purple and the leaf green.4. make the cayman travel 12,000 miles and the leaf 8,000 miles.5. change the price of the cayman to $50,000 and the price of the leaf to $ 24,500.6. call displaycarinfo on each object again to see how the instance variables have changed.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 06:30
Requirement types discussed during software development include functional and color scheme nonfunctional and code style constraint and nonfunctional fashionable and functional.
Answers: 2
question
Computers and Technology, 22.06.2019 23:30
Select all that apply. which of the following are proofreading options included in microsoft word? spell check find replace grammar check formatting check
Answers: 1
question
Computers and Technology, 23.06.2019 00:30
Write the html code to make a link out of the text “all about puppies”. it should link to a pdf called “puppies.pdf” inside the “documents” folder. the pdf should open in a new window.
Answers: 2
question
Computers and Technology, 23.06.2019 09:30
Facial expressions and gestures are examples of messages.
Answers: 3
You know the right answer?
Write a class named car that represents a car. your car class should have the followning: 1. instanc...
Questions
question
Mathematics, 03.07.2019 15:30
question
Biology, 03.07.2019 15:30
Questions on the website: 13722360