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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started