Computers and Technology

Write a class named car that has the following data attributes:

• _ _year_model (for the car’s year model)
• _ _make (for the make of the car)
• _ _speed (for the car’s current speed)

the car class should have an _ _init_ _ method that accepts the car’s year model and make
as arguments. these values should be assigned to the object’s _ _year_model and _ _make
data attributes. it should also assign 0 to the _ _speed data attribute.
the class should also have the following methods:

• accelerate
the accelerate method should add 5 to the speed data attribute each time it is called.
• brake
the brake method should subtract 5 from the speed data attribute each time it is called.
• get_speed
the get_speed method should return the current speed.
next, design a program that creates a car object and then calls the accelerate method
five times. after each call to the accelerate method, get the current speed of the car and
display it. then call the brake method five times. after each call to the brake method, get
the current speed of the car and display it.

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 18:30, yayamcneal05
Which cultural aspect does this type of song best portray? a german polka dance
Answers: 1
image
Computers and Technology, 23.06.2019 00:00, brooklyn4932
What engine component is shown in the above figure?
Answers: 1
image
Computers and Technology, 23.06.2019 01:20, shiann2002
Me with this program in c++ ! computers represent color by combining sub-colors red, green, and blue (rgb). each sub-color's value can range from 0 to 255. thus (255, 0, 0) is bright red. (130, 0, 130) is a medium purple. (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (in other word, equal amounts of red, green, blue yield gray).given values for red, green, and blue, remove the gray part. ex: if the input is 130 50 130, the output is: 80 0 80. thus, find the smallest value, and then subtract it from all three values, thus removing the gray.
Answers: 3
image
Computers and Technology, 23.06.2019 15:00, Siris420
Plz ( which is an example of a good url?
Answers: 1
Do you know the correct answer?
Write a class named car that has the following data attributes:

• _ _year_model (for th...

Questions in other subjects:

Konu
History, 18.10.2020 15:01