Question: please help 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

please help

please help Write a class named Car that has the following data

attributes: II year (for the car's year} make model speed (for the

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

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!