-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathins.py
More file actions
60 lines (46 loc) · 1.68 KB
/
Copy pathins.py
File metadata and controls
60 lines (46 loc) · 1.68 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
class Instrumento:
def __init__(self, nombre, tipo, precio):
self.nombre = nombre
self.tipo = tipo
self.precio = precio
self.__precio_coste = precio - 20
def tocar(self):
print(f"{self.nombre} está sonando.")
class Piano(Instrumento):
def __init__(self, nombre, tipo, precio, teclas, musico):
super().__init__(nombre, tipo, precio)
self.teclas = teclas
self.musico = musico
def tocar(self): # Estamos copiando
print(f"{self.musico.nombre} esta tocando: ding ding ding")
class Bateria(Instrumento):
def __init__(self, nombre, tipo, precio, tambores, platos):
super().__init__(nombre, tipo, precio)
self.tambores = tambores
self.platos = platos
def tocar(self):
print(f"{self.nombre} esta tocando: Tu-pa-tutu-pa!")
class Trompeta(Instrumento):
def __init__(self, nombre, tipo, precio, boquilla):
super().__init__(nombre, tipo, precio)
self.boquilla = boquilla
def tocar(self):
print(f"{self.nombre} esta tocando: Pa-pa-para-ba!!")
class Musico:
def __init__(self, nombre):
self.nombre = nombre
def tocar(self):
print(f"{self.nombre} esta tocando: Pa-pa-para-ba!!")
if __name__ == "__main__":
jon = Musico("Jon")
guitarra = Instrumento("Guitarra", "cuerdas", 100)
bateria = Instrumento("Bateria", "Percusión", 250)
guitarra.tocar()
piano1 = Piano("Piano X", "Cuerdas-Percusión", 200, 50, jon)
print(piano1.teclas)
piano1.tocar()
trompeta = Trompeta("Trompeta", "Metal", 175, True)
ego = Musico("Ego")
# jon = Musico("Jon")
piano1.musico = ego
piano1.tocar()