Question
Part 1: Design a Class Youll design a class named Car that has the following fields: yearModelAn Integer that holds the cars model year makeA
Part 1: Design a Class Youll 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 year model and make fields.
The constructor should also assign 0 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 5 to the speed field each time its called.
The brake method should subtract 5 from the speed field each time its called.
Create your class in a plain-text editor such as Notepad or TextEdit and save as a text file (*.txt).
Part 2: Design a Program Youll create both pseudocode and a flowchart to design a program that creates a Car object and then calls the accelerate method five times.
Write your pseudocode in a plain-text editor such as Notepad or TextEdit and save as a text file (*.txt).
Also, save a screenshot of your flowchart as a JPEG file (*.jpg).
After each call to the accelerate method, get the current speed of the car and display it.
Take a screenshot of the results after your fifth time calling the method, and save it as a JPEG file (*.jpg).
Then, call the brake method five times. After each call to the brake method, get the current speed of the car and display it.
Take a screenshot of the results after your fifth time calling the method, and save it as a JPEG file (*.jpg).
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