static void Main(string[] args) { FactoryProducer factoryProducer = new FactoryProducer(); AbstractFactory roundFactory = factoryProducer.getFactory(true); roundFactory.getShape("square").draw(); roundFactory.getShape("rectangle").draw(); AbstractFactory shapeFactory = factoryProducer.getFactory(false); shapeFactory.getShape("square").draw(); shapeFactory.getShape("rectangle").draw(); Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("Enter car(Audi or Mercedes): "); string car = Console.ReadLine(); Factory factory = FactoryProducer.getFactory(car); ITire tire = factory.makeTire(); tire.tire(); IHeadlight headlight = factory.makeHeadlight(); headlight.headlight(); Console.ReadLine(); }
static void Main(string[] args) { //get shape factory AbstractFactory shapeFactory = FactoryProducer.getFactory("SHAPE"); //get an object of Shape Circle Shape shape1 = shapeFactory.getShape("CIRCLE"); //call draw method of Shape Circle shape1.draw(); //get an object of Shape Rectangle Shape shape2 = shapeFactory.getShape("RECTANGLE"); //call draw method of Shape Rectangle shape2.draw(); //get an object of Shape Square Shape shape3 = shapeFactory.getShape("SQUARE"); //call draw method of Shape Square shape3.draw(); //get color factory AbstractFactory colorFactory = FactoryProducer.getFactory("COLOR"); //get an object of Color Red Color color1 = colorFactory.getColor("RED"); //call fill method of Red color1.fill(); //get an object of Color Green Color color2 = colorFactory.getColor("Green"); //call fill method of Green color2.fill(); //get an object of Color Blue Color color3 = colorFactory.getColor("BLUE"); //call fill method of Color Blue color3.fill(); Console.ReadLine(); }
static void Main(string[] args) { //Audi Factory factory = FactoryProducer.getFactory(true); //false for Audi ITire TireOfCar = factory.makeTire(); IHeadlight HeadlightOfCar = factory.makeHeadlight(); TireOfCar.tire(); HeadlightOfCar.headlight(); //Mercedes factory = FactoryProducer.getFactory(true); //true for Mercedes TireOfCar = factory.makeTire(); HeadlightOfCar = factory.makeHeadlight(); TireOfCar.tire(); HeadlightOfCar.headlight(); Console.ReadLine(); }
static void Main(string[] args) { PeopleFactory studentFactory = FactoryProducer.getFactory("STUDENT"); Student student1 = studentFactory.getStudent("CNPM"); student1.Info(); Student student2 = studentFactory.getStudent("HTTT"); student2.Info(); PeopleFactory employeeFactory = FactoryProducer.getFactory("EMPLOYEE"); Employee employee1 = employeeFactory.getEmployee("DuLich"); employee1.Work(); Employee employee2 = employeeFactory.getEmployee("BaoChi"); employee2.Work(); Console.ReadKey(); }