It's time to practice! Using what you've learned in the previous articles, create an App that meets the following requirements:
- Create a collection of objects that represent different types of vehicles.
- Use inheritance to have different types of vehicles with different properties and functions.
- GasCar: numberOfWheels, startEngine()
- ElectricCar: numberOfWheels, plug()
- Truck: numberOfWheels, startEngine()
- You'll need to use the following subclasses.
- GasVehicle
- ElectricVehicle
- DeliveryVehicle
- Avoid using protocols.
- Create a list of
Vehicle
. - Call
startEngine()
of eachVehicle
of your array.
This exercise has been created with the aim of compare Object Oriented Programming (OOP) with Protocol Oriented Programming (POP), which we used in a previous exercise here
Be the first to comment