This project is read-only.


This project was realized in C# using Visual Studio 2012.
The purpose of the project is to demonstrate 3 design patterns in a friendly way. The context of the project is that the user is working at a car dealership and can sell 3 types of cars (Coupe, Mini, Sedan). These cars have 3 common properties (name, color and transmission type) and 3 that are characteristic to each of the type. The program offers 4 options:
  1. Add a client
  2. Add a car
  3. Remove a car
  4. Print all cars
I will explain one by one the design patterns used:
  • Singleton: This was implemented using the class AppRunner.cs. In the main function of the project (in Program.cs) only one instance of this class is instantiated by calling the static method AppRunner.Instance()
  • Abstract Factory: For the use of this design pattern I used the abstract class AbstractCarFactory, which is then inherited by CarCoupeFactory, CarMiniFactory and CarSedanFactory. They all override the abstract method GetCar().
  • Object Pool: I implemented this design pattern in the AppRunner.cs class by using the wrapper CarPool.cs over a Queue object. 3 pools where needed for this example (one for each car type). When a new car is added into the system I get it from the pool if it is available, otherwise from the corresponding CarFactory class. Whenever a car is deleted from the system, if there is room, I put it back in the corresponding pool. The maximum number of the objects in pools is set in Program.cs when AppRunner.GeneratePools(int poolSize) is called.

Last edited Feb 21, 2013 at 10:53 PM by cervirgil, version 2


No comments yet.