static void Main(string[] args) { // ======== SIMPLE FACTORY =========== var smBank = SimpleFactory.getBank("DABank"); Console.WriteLine(smBank.getBankName()); //Console.Read(); // ======== FACTORY METHOD =========== IBank fmBank = FactoryMethod.getBank("ACBBank"); Console.WriteLine(fmBank.getBankName()); //Console.Read(); // ABSTRACT FACTORY - show screnario create factory and furniture IFurnitureAbstractFactory factory = FurnitureFactory.getFactory(MaterialType.FLASTIC); IChair chair = factory.createChair(); chair.create(); ITable table = factory.createTable(); table.create(); // ABSTRACT FACTORY - hide screnario create factory and furniture // can not use var c = ... IChair c = FurnitureFactory.createFurniture(MaterialType.WOOD, FurnitureType.CHAIR); c.create(); Console.Read(); }
static void Main(string[] args) { FurnitureAbstractFactory factory = FurnitureFactory.getFactory(MaterialType.FLASTIC); IChair chair = factory.createChair(); chair.create(); // Create plastic chair ITable table = factory.createTable(); table.create(); // Create plastic table }