static void Main(string[] args) { Console.WriteLine("**** FActory Pattern Demo ****\n"); IAnimalFactory tigerFactory = new TigerFactory(); IAnimal tiger = tigerFactory.MakeAnimal(); IAnimalFactory dogFactory = new DogFactory(); IAnimal dog = dogFactory.MakeAnimal(); Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("***Factory Pattern Demo***\n"); // Creating a Tiger Factory IAnimalFactory tigerFactory = new TigerFactory(); IAnimal tiger = tigerFactory.MakeAnimal(); // Creating a tiger using the Factory Method // IAnimal aTiger = tigerFactory.CreateAnimal(); // aTiger.Speak(); // aTiger.Action(); // Creating a DogFactory IAnimalFactory dogFactory = new DogFactory(); IAnimal dog = dogFactory.MakeAnimal(); // Creating a dog using the Factory Method // IAnimal aDog = dogFactory.CreateAnimal(); // aDog.Speak(); // aDog.Action(); Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("----- Factory Method Pattern Implementation -----"); Console.WriteLine(""); IAnimalFactory FactoryDog = new DogFactory(); IAnimal animal = FactoryDog.MakeAnimal(); //animal.Speak(); //animal.Action(); Console.WriteLine(""); IAnimalFactory FactoryCat = new CatFactory(); animal = FactoryCat.MakeAnimal(); //animal.Speak(); //animal.Action(); Console.Read(); }