public void SpawnAnimals()
        {
            _factory = FactoryProducer.GetFactory(FactoryType.Animal);

            _cat = _factory.GetAnimal(AnimalType.Cat);
            _dog = _factory.GetAnimal(AnimalType.Dog);

            _cat.Voice();
            _dog.Voice();
        }
        public void SpawnHumans()
        {
            _factory = FactoryProducer.GetFactory(FactoryType.Human);

            _beggar    = _factory.GetHuman(HumanType.Beggar);
            _farmer    = _factory.GetHuman(HumanType.Farmer);
            _shopOwner = _factory.GetHuman(HumanType.ShopOwner);

            _beggar.Speak();
            _farmer.Speak();
            _shopOwner.Speak();
        }
Ejemplo n.º 3
0
        private static void Main()
        {
            //get shape factory
            var shapeFactory = FactoryProducer.GetFactory(false);

            //get an object of Shape Rectangle
            var rectangle = shapeFactory.GetShape(Rectangle.ShapeName);

            //call draw method of Shape Rectangle
            rectangle.Draw();

            //get an object of Shape Square
            var square = shapeFactory.GetShape(Square.ShapeName);

            //call draw method of Shape Square
            square.Draw();

            //-----
            //get rounded shape factory
            shapeFactory = FactoryProducer.GetFactory(true);

            //get an object of Shape Rectangle
            var roundedRectangle = shapeFactory.GetShape(RoundedRectangle.ShapeName);

            //call draw method of Shape Rectangle
            roundedRectangle.Draw();

            //get an object of Shape Square
            var roundedSquare = shapeFactory.GetShape(RoundedSquare.ShapeName);

            //call draw method of Shape Square
            roundedSquare.Draw();

            Console.Write(@"Press any key to continue...");
            Console.ReadKey(true);
        }