Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to create a python program based on pseudocode from a car class definitio

ID: 3698271 • Letter: I

Question

I need to create a python program based on pseudocode from a car class definition and main program.

The car class pseudocode represented the design for a class named Car that had the following fields:

yearModel

make

speed

as well as the constructor, accessor, accelerate, brake, and mutator.

The program should create a car object and then call 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.

Explanation / Answer

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: class Car: def __init__(self, year_model, make, speed): self.year_model = year_model self.make = make self.speed = 0 def setYear_model(self, year_model): self.year_model = year_model def getYear_model(self): return self.year_model def setMake(self, make): self.make = make def getMake(self): return self.make def setSpeed(self, speed): if speed < 0: print("Speed cannot be negative") else: self.speed = speed def getSpeed(self): return self.speed def accelerate(self, speed): self.speed += 5 return self.speed def brake(self, speed): self.speed -= 5 return self.speed def __str__(self): return "Make : " + self.make + ", Model Year :" + self.year_model + ", speed =" + str(self.speed)
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote