From 80e590a400ddb47032c619f0aa15c2a58f19fc0b Mon Sep 17 00:00:00 2001 From: tlizri Date: Tue, 8 Nov 2022 20:52:12 +0100 Subject: [PATCH 1/2] Completed exercise six-a --- src/exercisesix/vehiculo.py | 36 ++++++++++++++++++++++++++++++++++++ src/main.py | 12 ++++++++++-- 2 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 src/exercisesix/vehiculo.py diff --git a/src/exercisesix/vehiculo.py b/src/exercisesix/vehiculo.py new file mode 100644 index 0000000..69947df --- /dev/null +++ b/src/exercisesix/vehiculo.py @@ -0,0 +1,36 @@ +class Vehiculo: + """Conceptual representation of a vehicle + :param color: representation of vehicle color + :type color: str + :param ruedas: number of wheels + :type ruedas: int + :param puertas: number of doors + :type puertas: int + """ + def __init__(self, color='', ruedas=-1, puertas=-1): + """Constructor method + """ + self.color = color + self.ruedas = ruedas + self.puertas = puertas + + +class Coche(Vehiculo): + """Conceptual representation of a car that inherits from vehicle + :param velocidad: car speed + :type velocidad: int + :param cilindrada: car cylinder + :type cilindrada: int + :param color: representation of vehicle color + :type color: str + :param ruedas: number of wheels + :type ruedas: int + :param puertas: number of doors + :type puertas: int + """ + def __init__(self, velocidad=-1, cilindrada=-1, color='', ruedas=-1, puertas=-1): + """Constructor method + """ + super().__init__(color, ruedas, puertas) + self.velocidad = velocidad + self.cilindrada = cilindrada diff --git a/src/main.py b/src/main.py index a47b6a3..69cf639 100644 --- a/src/main.py +++ b/src/main.py @@ -1,9 +1,17 @@ +from src.exercisesix.vehiculo import Coche + + def main(): - """Main script for pythonBootCamp project + """Main script for exercise six-a :return: None :rtype: NoneType """ - pass + micoche = Coche(cilindrada=1299, velocidad=180, color='rojo', ruedas=4, puertas=5) + print('Cilindradas:', micoche.cilindrada, 'cc') + print('Velocidad:', micoche.velocidad, 'km/h') + print('Color:', micoche.color) + print('Ruedas:', micoche.ruedas) + print('Puertas:', micoche.puertas) if __name__ == '__main__': From 3d50c2d8d482ba5c83d44e3e856464cd977ba3f4 Mon Sep 17 00:00:00 2001 From: Izri Toufali Lapaz Date: Tue, 8 Nov 2022 20:57:24 +0100 Subject: [PATCH 2/2] Update README.md --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index fa0237d..202f441 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,19 @@ # OpenBootCampPython Repository to store Python boot camp. +* Ejercicio 6.A: + + En este ejercicio vais a crear la clase Vehículo la cual tendrá los siguientes atributos: + + * Color + + * Ruedas + + * Puertas + + Por otro lado crearéis la clase Coche la cual heredará de Vehículo y tendrá los siguientes atributos: + + * Velocidad + + * Cilindrada + + Por último, tendrás que crear un objeto de la clase Coche y mostrarlo por consola.