-
Notifications
You must be signed in to change notification settings - Fork 0
/
A22.py
32 lines (31 loc) · 844 Bytes
/
A22.py
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
30
31
32
class carro:
velMax = 0
ligado = False
cor = ""
def __init__(self,v,l,c):
self.velMax = v
self.ligado = l
self.cor = c
def mostrar(self):
print("Velocidade Maxima: " + str(self.velMax))
print("Cor: " + str(self.cor))
estado = "Sim" if self.ligado else "nao" #Operador Ternário
print("Ligado: " + str(estado))
print("---------------------------------------------------")
def ligar(self):
self.ligado = True
def desligar(self):
self.ligado = False
def andar(self):
if self.ligado:
print("Andando....")
else:
print("Carro desligado..")
c1 = carro(200,False,"Preto")
c2 = carro(120,False, "Branco")
c3 = carro(350, False, "Vermelho")
c1.ligar()
c2.andar()
c1.mostrar()
c2.mostrar()
c3.mostrar()