Skip to content

Commit dfa07b8

Browse files
committed
direção e motor
1 parent a29527f commit dfa07b8

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

OO/carro.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
NORTH = 'Norte'
2+
SOUTH = 'Sul'
3+
EAST = 'East'
4+
WEST = 'Oeste'
5+
class Motor:
6+
def __init__(self):
7+
self.velocidade = 0
8+
9+
def acelerar(self):
10+
self.velocidade += 1
11+
def frear(self):
12+
self.velocidade -= 2
13+
self.velocidade = max(0, self.velocidade)
14+
15+
16+
class Direcao:
17+
rotation_right_dct = {NORTH: EAST, EAST: SOUTH,SOUTH: WEST}
18+
rotation_left_dct = {NORTH: WEST, WEST: SOUTH, SOUTH: EAST}
19+
def __init__(self):
20+
self.valor = NORTH
21+
22+
def turn_right(self):
23+
self.valor = self.rotation_right_dct[self.valor]
24+
def turn_left(self):
25+
self.valor = self.rotation_left_dct[self.valor]

0 commit comments

Comments
 (0)