-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclase_abstracta.py
More file actions
47 lines (24 loc) · 992 Bytes
/
clase_abstracta.py
File metadata and controls
47 lines (24 loc) · 992 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
35
36
37
38
39
40
41
42
43
44
45
46
from abc import ABC,abstractmethod
class Persona(ABC):
def __init__(self, name:str, age:int) -> None:
self.name=name
self.age=age
@abstractmethod
def saludar(self):
return F"Saludar es mandatorio {self.name}"
def saludar_pro(self):
return F"Saludar como PRO no es mandarorio {self.name}"
class Medico(Persona):
operaciones=None
def __init__(self, name: str, age: int, especialidad:str, hospital:str|None=None) -> None:
super().__init__(name, age)
self.especialidad=especialidad
self.hospital=hospital
def saludar(self):
return F"Hola soy {self.name}"
def addOperations(self,opNumber:int):
self.operaciones=opNumber
return "Operaciones agregadas !"
medico1= Medico('Guillermo',60,"Cirujano Plastico")
print(medico1.addOperations(22))
print(medico1.operaciones)