Question: design a class named Car that has the following fields: yearModel An Integer that holds the car s model year make A String that holds
design a class named Car that has the following fields:
yearModelAn Integer that holds the cars model year
makeA String that holds the make of the car
speedAn Integer that holds the cars current speed
The class should have the following constructor and other methods:
The constructor should accept the cars model year and make as arguments. These values should be assigned to the objects yearModel and make fields. The constructor should also assign to the speed field.
Design appropriate accessor methods to get the values stored in an objects yearModel, make, and speed fields.
The accelerate method should add to the speed field each time its called.
The brake method should subtract from the speed field each time its called.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
