public void TestAbstractHondaFactorySedanInstance() { ISedan sedan = hondaFactory.GetSedan(); Assert.IsNotNull(sedan); Assert.IsInstanceOfType(sedan, typeof(HondaCity)); }
public void TestAbstractFordFactorySedanInstance() { ISedan sedan = fordFactory.GetSedan(); Assert.IsNotNull(sedan); Assert.IsInstanceOfType(sedan, typeof(Fiesta)); }
static void Main(string[] args) { Console.WriteLine("Start testing Abstract Factory Pattern"); //Trying out Abstract Factory IStampingEquipment equipment = new StampingSportsEquipment(); IDoor door = equipment.StampDoor(); IHood hood = equipment.StampHood(); IWheel wheel = equipment.StampWheel(); Console.WriteLine("End testing Abstract Factory Pattern"); Console.WriteLine(); Console.WriteLine("Start testing Abstract Factory Pattern 2 "); //Trying out Abstract Factory again ICarFactory fordFactory = new FordFactory(); ISedan sedan = fordFactory.CreateSedan(); ISUV suv = fordFactory.CreateSUV(); AbstractFactorySample2.IConvertible convertible = fordFactory.CreateConvertible(); sedan.PrintName(); suv.PrintName(); convertible.PrintName(); Console.WriteLine("End testing Abstract Factory Pattern 2"); Console.WriteLine(); //Trying out Builder factory again Console.WriteLine("Start testing Builder Pattern"); var director1 = new EverythingDirector(new BasicCoreBuilder(), new BasicMeatBuilder(), new BasicVeggieBuilder()); var director2 = new VeggieDirector(new BasicCoreBuilder(), new FancyVeggieBuilder()); Console.WriteLine(director1.MakePizza()); Console.WriteLine(director2.MakePizza()); Console.WriteLine("End testing Builder Pattern"); }
public CarClientAbstractFactory(ICarFactory factory, string segment) { sedan = factory.ManufactureSedan(segment); suv = factory.ManufactureSuv(segment); }
static void Main(string[] args) { /*Console.WriteLine("In Cracow Client can buy following cars (luxurious): "); * Console.WriteLine(new CracowFactory()); * * Console.WriteLine(); * * Console.WriteLine("In Bialystok Client can buy following cars (common): "); * new BialystokFactory(); * * Console.WriteLine(); * * Console.WriteLine("In Warsaw Client can buy following eco cars: "); * new WarsawFactory(); */ /* * List<ICarFactory> carFactories = new List<ICarFactory>(); * carFactories.Add(new CracowFactory()); * carFactories.Add(new BialystokFactory()); * carFactories.Add(new WarsawFactory()); * * foreach(ICarFactory factory in carFactories) * { * ISUV s = factory.DesignSUV(); * Console.WriteLine(s.SUV() + " PLN" + s.Price); * Console.WriteLine("------------------------"); * * ISedan d = factory.DesignSedan(); * Console.WriteLine(d.Sedan() + " PLN" + d.Price); * Console.WriteLine("------------------------"); * * ICoupe c = factory.DesignCoupe(); * Console.WriteLine(c.Coupe() + " PLN" + c.Price); * Console.WriteLine("------------------------"); * }*/ Console.WriteLine("In Cracow factory client can order: "); ICarFactory factoryA = new CracowFactory(); ISUV SUVA = factoryA.DesignSUV(); Console.WriteLine(SUVA.SUV() + " PLN" + SUVA.Price); ISedan sedanA = factoryA.DesignSedan(); Console.WriteLine(sedanA.Sedan() + " PLN" + sedanA.Price); ICoupe coupeA = factoryA.DesignCoupe(); Console.WriteLine(coupeA.Coupe() + " PLN" + coupeA.Price); Console.WriteLine(); Console.WriteLine("In Warsaw factory client can order: "); ICarFactory factoryB = new WarsawFactory(); ISUV SUVB = factoryB.DesignSUV(); Console.WriteLine(SUVB.SUV() + " PLN" + SUVB.Price); ISedan sedanB = factoryB.DesignSedan(); Console.WriteLine(sedanB.Sedan() + " PLN" + sedanB.Price); ICoupe coupeB = factoryB.DesignCoupe(); Console.WriteLine(coupeB.Coupe() + " PLN" + coupeB.Price); Console.WriteLine(); Console.WriteLine("In Bialystok factory client can order: "); ICarFactory factoryC = new BialystokFactory(); ISUV SUVC = factoryC.DesignSUV(); Console.WriteLine(SUVC.SUV() + " PLN" + SUVC.Price); ISedan sedanC = factoryC.DesignSedan(); Console.WriteLine(sedanC.Sedan() + " PLN" + sedanC.Price); ICoupe coupeC = factoryC.DesignCoupe(); Console.WriteLine(coupeC.Coupe() + " PLN" + coupeC.Price); }
public CarClient(ICarFactory factory, Segment segment) { sedan = factory.ManufactureSedan(segment); suv = factory.ManufactureSuv(segment); }
public SedanAdapter(ISedan g) { this.g = g; }