Last active
October 31, 2017 13:18
-
-
Save ysnerdem/0f24a5d1e8c5abdc56a7e44e9c313924 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Car: | |
def __init__(self): | |
self.make = "Lamborghini" | |
self.model = "Gallardo" | |
self.car_segment = "supercars" | |
self.year = "2013" | |
self.body_style = "coupe" | |
self.top_speed = 325 | |
self.speed = 0 | |
self.gas = 0 | |
def show_room(self): | |
print("Make:", self.make, "Model:", self.model, "Car segment:", self.car_segment, | |
"Year:", self.year, "Boddy style:", self.body_style) | |
def speedrun(self): | |
self.gas += 1 | |
if self.speed < self.top_speed and self.gas < 3: | |
self.speed += 60 | |
print(self.speed, "km/h") | |
elif self.speed < self.top_speed and self.gas < 5: | |
self.speed += 45 | |
print(self.speed, "km/h") | |
elif self.speed < self.top_speed and self.gas < 8: | |
self.speed += 30 | |
print(self.speed, "km/h") | |
elif self.speed < self.top_speed and self.gas >= 8: | |
self.speed += 25 | |
print(self.speed, "km/h") | |
elif self.speed == self.top_speed: | |
print("you are at your highest speed", self.speed) | |
else: | |
print("uncomment action") | |
def brake(self): | |
if self.speed > 0: | |
self.speed -= 50 | |
if self.speed == 0: | |
print("the car stopped") | |
car = Car() | |
while True: | |
print("Choose action**") | |
print("(q)Show car") | |
print("(w)Gas") | |
print("(s)brake") | |
action = input("Enter action:") | |
if action == "q": | |
car.show_room() | |
elif action == "w": | |
car.speedrun() | |
elif action == "s": | |
car.brake() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment