Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Design a class named Car that has the following fields: yearModel: an int instance variable that holds the cars year model. make: a string instance
Design a class named Car that has the following fields:
- yearModel: an int instance variable that holds the cars year model.
- make: a string instance variable that holds the make of the car.
- speed: an int instance variable that holds the cars current speed.
In addition, the class should have the following methods.
- Constructor 1: no-arg constructor set the yearModel, make and speed to 2000, Nissan and 4, respectively.
- Constructor 2: this is an overloaded constructor. This constructor should accept the cars year model, speed, and make as arguments. These values should be assigned to the objects yearModel, speed and make fields.
- Accessor (getters): appropriate accessor methods to get the values stored in an objects yearModel, make, and speed fields.
- Mutator (setters): appropriate mutator methods to store values in an objects yearModel, make, and speed fields.
- toString: returns a string describing the objects yearModel, make and speed.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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