-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcar.py
More file actions
29 lines (23 loc) · 677 Bytes
/
car.py
File metadata and controls
29 lines (23 loc) · 677 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class Car:
Foo = "A"
def __init__(self, v=0, car_name="Def_name"):
self.name = car_name
self.coordinate_x = 0
self.coordinate_y = 0
self.velocity = v
self.direction = 0
def move_forward(self, speed):
self.velocity = speed
def turn_right(self, angle):
self.direction -= angle
def turn_left(self, angle):
self.direction += angle
def stop(self):
self.velocity = 0
def __del__(self):
print("Car", self.name, "moved out of frame.")
self.coordinate_x = 0
self.coordinate_y = 0
self.velocity = 0
self.direction = 0
self.name = ""