Question
C# code help: Write a class named Car that has the following data attributes: year_model (for the cars year_model) make (for the make of the
C# code help:
Write a class named Car that has the following data attributes:
year_model (for the cars year_model)
make (for the make of the car)
speed (for the cars current speed)
The car class must have a method that accepts the cars year_model and make as arguments. These values should be assigned to the cars year_model and make data attributes. It should also assign zero to the speed data attribute.
The class should also have the following methods:
accelerate
The accelerate method should and five to the speed data attribute each time it is called.
break
The break method should subtract five from the speed data attribute each time it called.
speed
The current_speed methodshould return the current speed.
Next, create a main (driver)class that instantiates a Car object. Then it should call the accelerate method five times and after each call to the accelerator method, get the current speed of the car and display it. Next, call the break method five times. After each call to the break method, get the current speed of the car and display it.
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