Question: How to write a car class with: private instance variables name, mpg, and one other attribute of your choice public methods getters and setters equals-checks
How to write a car class with:
private instance variables
name, mpg, and one other attribute of your choice
public methods
getters and setters
equals-checks if two cars have the same attributes
create a method of your own(e.g. sellCar, openDoor, closeDoor, etc.)
Create two constructors for this class
> in a separate file, create a CompareCars class with main()method
Create two instances of Car using different constructors
compare the fuel efficiency of your 2 cars and print out which is more efficient screen
use getters
Use equals method to determine if the cars have the properties
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
