-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPOOII.py
More file actions
46 lines (34 loc) · 1.25 KB
/
POOII.py
File metadata and controls
46 lines (34 loc) · 1.25 KB
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
33
34
35
36
37
38
39
40
41
42
43
class Coche():
def __init__(self):
self.__largoChasis=250
self.__anchoChasis=120
self.__ruedas=4 #variable encapsulada
self.__enmarcha=False
def arrancar(self,arrancamos):
self.__enmarcha = arrancamos
if (self.__enmarcha):
chequeo=self.__chequeoInterno()
if (self.__enmarcha and chequeo):
return "El coche esta en marcha"
elif(self.__enmarcha and chequeo==False):
return "Algo ha salido mal durante el chequeo"
else:
return "El coche esta parado"
def estado(self):
print("El coche tiene {} ruedas. Un ancho de {} y un largo de {} \n".format(self.__ruedas,self.__anchoChasis,self.__largoChasis))
def __chequeoInterno(self):
print("Realizando chequeo interno")
self.gasolina="ok"
self.aceite="ok"
self.puertas="cerradas"
if (self.gasolina=="ok" and self.aceite=="ok" and self.puertas=="cerradas"):
return True
else:
return False
jetta = Coche()
print(jetta.arrancar(True))
jetta.estado()
print("----------------------A continuacion creamos el segundo objeto------------------------\n")
vochito = Coche()
print(vochito.arrancar(False))
vochito.estado()