There is a factory in Riyadh that produces vehicles π (cars, bicycles and motorcycles), and it needs to keep tracking of all the different vehicles it produces. And since you are now a good Swift programmer π€π», they asked you to build a system for them that fits with their needs. And since you have a good experience in OOP (object oriented programming) you are required to make a good structure for making the system.
- There should be a
Factoryclass that represents the factory. - Also, there should be a
Vehicleclass that represents the vehicles generated from the factory. - Since you have three types of vehicles, you should make a class for each one of them; these are: 1- Bicycle. 2- Motorcycle. 3- Car.
- All these three classes are actually vehicles, therefore, they should inherit from the
Vehicleclass. - The factory produces vehicles, thus, it should have an association with many
Vehicleobjects (array). I won't tell you what the relation is; you should know what it should be based on the business requirements or based on the drawing shown below. - The factory should allow the user to add a vehicle using a method named
addVehicle. - Each
Vehicleshould have anameandmodelasStringattributes; these two attributes should be filled whenever a new object is made fromVehicleor any of its subclasses. - You should make a method in the
Factoryclass namedprintVehiclesthat prints all the vehicles' names that tha factory produced. - You should also make a method in the
Factoryclass namedremoveVehiclethat removes a vehicle from the factory based on thenamepassed to this function.
The needed system is illustrated in this diagram, you can use it to understand the general idea of what is required from you in this assignment.

Please make the system as described above and then answer this question at this file in the next line after the question
- What is the type of the association used between the
FactoryandVehicle? and why?
(replace this line with your answer)
- Make sure you create a new folder in your computer, fork the project to your account, clone your version of the code nto the folder you made, and finally create a new xcode project in that folder and start working from there.
- You should make each class in a separate file.
- You should use the
mainfile to create thefactoryand make at least 7Vehicle (Bicycle - Motorc... etc)objects. - Then you should add these vehicles to the factory.
- Then print the vehicles you have in the factory using the method
printVehicles. - And finally, remove some vehicles using the method
removeVehicleand print the vehicles again.
Gooooood Luck π₯ π