static void Main(string[] args) { var factory = FactoryProvider.GetFactory("shape"); var shape = factory.GetShape("circle"); shape.DrawShape(); shape = factory.GetShape("square"); shape.DrawShape(); factory = FactoryProvider.GetFactory("color"); var color = factory.GetColor("red"); color.DrawColor(); color = factory.GetColor("blue"); color.DrawColor(); Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("Abstract Factory Pattern"); //making a wild dog and a wild tiger with WildAnimalFactory IAnimalFactory animalFactory = FactoryProvider.GetAnimalFactory(AnimalType.Wild); IDog dog = animalFactory.GetDog(); ITiger tiger = animalFactory.GetTiger(); dog.AboutMe(); tiger.AboutMe(); Console.WriteLine("--------------------------------------------------------"); //making a pet dog and a pet tiger with PetAnimalFactory animalFactory = FactoryProvider.GetAnimalFactory(AnimalType.Pet); dog = animalFactory.GetDog(); tiger = animalFactory.GetTiger(); dog.AboutMe(); tiger.AboutMe(); Console.Read(); }
static void Main(string[] args) { Console.WriteLine("***Abstract Factory Pattern Demo.***\n"); //Making a wild dog and wild tiger through WildAnimalFactory IAnimalFactory animalFactory = FactoryProvider.GetAnimalFactory("wild"); IDog dog = animalFactory.GetDog(); ITiger tiger = animalFactory.GetTiger(); dog.AboutMe(); tiger.AboutMe(); Console.WriteLine("******************"); //Making a pet dog and pet tiger through PetAnimalFactory now. animalFactory = FactoryProvider.GetAnimalFactory("pet"); dog = animalFactory.GetDog(); tiger = animalFactory.GetTiger(); dog.AboutMe(); tiger.AboutMe(); Console.ReadLine(); }