Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
36 changes: 36 additions & 0 deletions src/exercisesix/vehiculo.py
Original file line number Diff line number Diff line change
@@ -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
12 changes: 10 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -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__':
Expand Down