Swift

Mini Project - Car Rentals

Applying classes to real life

Context

For this project, you will develop a program that provides information useful to people looking to rent a car. You are a car rental sales person and your job is to provide details about all of the cars on the lot.

Task

You will need to write a class for the general concept of a Car. This class should have the basic feature of all cars: 4 wheels. The other essential features cost and year should be passed through the init() method. Then, you should create child classes for two general types of cars, the sedan and the coupe. As we know, coupes typically have 2 seats, whereas sedans have 5. So put this info into the classes with variable seats.

Then, add a description function to the child classes that provide a description of the car using all the available info: wheels, seats, cost, and year. Finally, create 4 cars of your liking using these child classes, and print out their descriptions to the console using a for loop and array! Have fun!

chevron_up