Challenge: Creating a Vehicle Hierarchy
Tarea
Swipe to start coding
Define a class hierarchy for different types of vehicles:
- Create a base class named
Vehiclewith an__init__method that takesbrandandspeedas arguments. - Add a method called
get_infotoVehiclethat returns the brand and speed. - Create a subclass
Carthat inherits fromVehicleand adds adoorsattribute. - Create a subclass
Bikethat inherits fromVehicleand adds atypeattribute (such as'mountain'or'road'). - Override the
get_infomethod in bothCarandBiketo include their extra data (doorsfor cars,typefor bikes).
Solución
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 1. Capítulo 10
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Genial!
Completion tasa mejorada a 3.85
Challenge: Creating a Vehicle Hierarchy
Desliza para mostrar el menú
Tarea
Swipe to start coding
Define a class hierarchy for different types of vehicles:
- Create a base class named
Vehiclewith an__init__method that takesbrandandspeedas arguments. - Add a method called
get_infotoVehiclethat returns the brand and speed. - Create a subclass
Carthat inherits fromVehicleand adds adoorsattribute. - Create a subclass
Bikethat inherits fromVehicleand adds atypeattribute (such as'mountain'or'road'). - Override the
get_infomethod in bothCarandBiketo include their extra data (doorsfor cars,typefor bikes).
Solución
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 1. Capítulo 10