Menu

(Solved) : Write Class Named Car Following Data Attributes Ii Year Car S Year Make Model Speed Car S Q43982742 . . .

please help

Write a class named Car that has the following data attributes: II year (for the cars year} make model • speed (for the car

e cars year, model, and ute. the speed attribute each time e speed data attribute each e cars current speed. lls the accele

Write a class named Car that has the following data attributes: II year (for the car’s year} make model • speed (for the car’s current speed) The Car class should have an make data attributes. It should also assign 0 to the speed attribute. init_method that accepts the car’s year, model, arn The class should also have the following methods: accelerate – The accelerate method should add 5 to the speed attribute each it is called. brake – The brake method should subtract 5 from the speed data attribute ea time it is called. get_speed – The get speed method should return the car’s current speed. Next, design a program that creates a Car object and then calls the accelerate methc five times. After each call to the accelerate method, get the current speed of the car display it. Then call the brake method five times. After each call of the brake metho get the current speed of the car and display it. Sample Program Output: car is accelerating: Current speed: 5 Current speed: 10 Current speed: 15 Current speed: 20 Current speed: 25 car is braking: Current speed: 20 Current speed: 15 Current speed: 10 Current speed: 5 Current speed: 0 <<< e car’s year, model, and ute. the speed attribute each time e speed data attribute each e car’s current speed. lls the accelerate method current speed of the car and call of the brake method, Show transcribed image text Write a class named Car that has the following data attributes: II year (for the car’s year} make model • speed (for the car’s current speed) The Car class should have an make data attributes. It should also assign 0 to the speed attribute. init_method that accepts the car’s year, model, arn The class should also have the following methods: accelerate – The accelerate method should add 5 to the speed attribute each it is called. brake – The brake method should subtract 5 from the speed data attribute ea time it is called. get_speed – The get speed method should return the car’s current speed. Next, design a program that creates a Car object and then calls the accelerate methc five times. After each call to the accelerate method, get the current speed of the car display it. Then call the brake method five times. After each call of the brake metho get the current speed of the car and display it. Sample Program Output: car is accelerating: Current speed: 5 Current speed: 10 Current speed: 15 Current speed: 20 Current speed: 25 car is braking: Current speed: 20 Current speed: 15 Current speed: 10 Current speed: 5 Current speed: 0

Expert Answer


Answer to Write a class named Car that has the following data attributes: II year (for the car’s year} make model • speed (for t…

OR