-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoo.py
More file actions
34 lines (26 loc) · 901 Bytes
/
poo.py
File metadata and controls
34 lines (26 loc) · 901 Bytes
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
class humano():
def __init__(self,nombre, edad):
self.nombre = nombre
self.edad = edad
def __eq__(self,objeto):
if self.nombre == objeto.nombre and self.edad == objeto.edad: #Aqui estoy comparando los campos de dos objetos, si se llaman igual y tienen la misma edad, saldra que si son iguales. Pero en sí, son dos objetos diferentes
return True
else:
return False
def mayorEdad(self):
if self.edad > 17:
return True
else:
return False
miHumano1=humano("monica", 23)
miHumano2=humano("pablo", 29)
miHumano3=humano("paula", 41)
if miHumano1 == miHumano2:
print("son iguales")
else:
print("no son iguales")
listaTotal = []
listaTotal.append(miHumano1)
listaTotal.append(miHumano2)
listaTotal.append(miHumano3)
print(listaTotal)