Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit cbc04eb

Browse files
author
Kristoffer-Hallam
committed
Implementação do carro
1 parent 1e32283 commit cbc04eb

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

oo/carro.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,29 @@
9494
'O'
9595
"""
9696

97+
class Carro:
98+
def __init__(self, motor, direcao):
99+
self.direcao = direcao
100+
self.motor = motor
101+
102+
def calcular_velocidade(self):
103+
return self.motor.velocidade
104+
105+
def acelerar(self):
106+
self.motor.acelerar()
107+
108+
def frear(self):
109+
self.motor.frear()
110+
111+
def calcular_direcao(self):
112+
return self.direcao.valor
113+
114+
def girar_a_direita(self):
115+
self.direcao.girar_a_direita()
116+
117+
def girar_a_esquerda(self):
118+
self.direcao.girar_a_esquerda()
119+
97120
NORTE = 'N'
98121
SUL = 'S'
99122
LESTE = 'L'
@@ -127,5 +150,5 @@ def frear(self):
127150
self.velocidade -= 2
128151
self.velocidade = max(0, self.velocidade)
129152

130-
if __name__ == '__main__':
131-
carro = Carro
153+
# if __name__ == '__main__':
154+
# carro = Carro

0 commit comments

Comments
 (0)