M3.6
Sun Oct 31 2021 10:17:23 GMT+0000 (Coordinated Universal Time)
Saved by
@kuba
class Vehiculo():
def __init__(self, color, ruedas):
self.color = color
self.ruedas = ruedas
print("\n El vehículo se ha creado con éxito!")
def __str__(self):
info = "Color: " + self.color + "\n Ruedas: " + str(self.rueadas)
return info
class Coche (Vehiculo):
def __init__(self, color, ruedas, velocidad, cilindrada):
self.velocidad = velocidad
self.cilindrada = cilindrada
super().__init__(color, ruedas)
def __str__ (self):
info = "\n Coche \n Color: " + self.color + "\n Ruedas: " + str(self.ruedas) + "\n Velocidad: " + str(self.velocidad) + "\n Cilindrada: " + str(self.cilindrada)
return info
coche1 = Coche("Rojo", 4, 200, 500)
print(coche1)
coche2 = Coche("Blanco", 4, 170, 450)
print(coche2)
coche3 = Coche("Negro", 4, 250, 650)
print(coche3)
content_copyCOPY
Comments