Question: Car.java: Create a class named Car that has the following instance variablesCor attributes): o yearModel holds the car's year model. o make holds the make
Car.java: Create a class named Car that has the following instance variablesCor attributes): o yearModel holds the car's year model. o make holds the make of the car o Speed holds the car's current speed. The class should have the following constructors o default constructorniial default values o parameterized constructoraccepts arguments for all attributes from the main() methoo . . For each instance variable or attibute), the class should contain Matators modifie the values sored n an bjects earndodel, make andspe fes valid. Otherwise, it displays an error message on the console. Create the following methods: . equals- to check if two car objects contain the same value. Returns true or false toString accelerate-The accelerate method should add 5 to the speed field each time it is called. Retu nothing o returns the attributes of an object. Returns a string value. o o brake The brake method should subtract 5 from the speed field each time it is called. Returr nothing
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
