Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create the following C# code Write a class named Car that has the following data attributes: year_model (for the cars year_model) make (for the make

Create the following C# code

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Find the derivative of y= cos cos (x + 2x)

Answered: 1 week ago