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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!