subject

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.

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:20, destinyleisantos
The kurt vonnegut commencement speech, the neiman-marcus chocolate chip cookie recipe, and the get-well emails to the dying boy are examples of select one: a. social engineering b. hoax emails c. email viruses d. worms
Answers: 1
image
Computers and Technology, 24.06.2019 18:30, WATBOI01
What is the local portion of the e-mail address below? twrigley@gumchewer. biz a.) @ b.) biz c.) gumchewer d.) twrigley
Answers: 1
image
Computers and Technology, 25.06.2019 08:40, drealtania21
Anyone took cgs 1060 and took exam for simnet, slide 50 question on 1st exam.
Answers: 3
image
Computers and Technology, 25.06.2019 14:30, sunny6946
How can i cancel my subscription in
Answers: 1
You know the right answer?
Write a class named car that has the following data attributes:

• _ _year_model (for th...

Questions in other subjects:

Konu
Computers and Technology, 18.03.2021 01:40
Konu
Mathematics, 18.03.2021 01:40
Konu
History, 18.03.2021 01:40