Skip to content

Commit a6600bf

Browse files
committed
Atributo compostos 1.4
1 parent 026f0a9 commit a6600bf

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

oo/carro.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
>>> motor.velocidade
3636
1
3737
>>> motor.frear()
38-
>>> motor.velocidad
38+
>>> motor.velocidade
3939
0
4040
>>> # Testando Direção
4141
>>> direcao = Direcao()
@@ -90,6 +90,15 @@
9090
>>> 'Oeste'
9191
"""
9292

93+
NORTE = 'Norte'
94+
SUL = 'Sul'
95+
LESTE = 'Leste'
96+
OESTE = 'Oeste'
97+
98+
99+
class Direcao:
100+
def __init__(self):
101+
self.valor = NORTE
93102
class Motor:
94103
def __init__(self):
95104
self.velocidade = 0
@@ -99,3 +108,5 @@ def acelerar(self):
99108

100109
def frear(self):
101110
self.velocidade -= 2
111+
self.velocidade = max(0, self.velocidade)
112+

0 commit comments

Comments
 (0)