Example #1
0
        protected override EnemyShip MakeEnemyShip(string typeOfShip)
        {
            EnemyShip theEnemyShip = null;

            // If UFO was sent grab use the factory that knows
            // what types of weapons and engines a regular UFO
            // needs. The EnemyShip object is returned & given a name
            IEnemyShipFactory shipPartsFactory = new UFOEnemyShipFactory();

            if (typeOfShip == "UFO")
            {
                theEnemyShip      = new UFOEnemyShip(shipPartsFactory);
                theEnemyShip.Name = "UFO Grunt Ship";
            }
            // If UFO BOSS was sent grab use the factory that knows
            // what types of weapons and engines a Boss UFO
            // needs. The EnemyShip object is returned & given a name
            else if (typeOfShip == "UFO BOSS")
            {
                theEnemyShip      = new UFOBossEnemyShip(shipPartsFactory);
                theEnemyShip.Name = "UFO Boss Ship";
            }

            return(theEnemyShip);
        }
        // When called a new EnemyShip is made. The specific parts
        // are based on the String entered. After the ship is made
        // we execute multiple methods in the EnemyShip Object

        public EnemyShip OrderTheShip(string typeOfShip)
        {
            EnemyShip theEnemyShip = MakeEnemyShip(typeOfShip);

            theEnemyShip.MakeShip();
            theEnemyShip.DisplayEnemyShip();
            theEnemyShip.FollowHeroShip();
            theEnemyShip.EnemyShipShoots();

            return(theEnemyShip);
        }
Example #3
0
        static void Main(string[] args)
        {
            // EnemyShipBuilding handles orders for new EnemyShips
            // You send it a code using the orderTheShip method &
            // it sends the order to the right factory for creation

            EnemyShipBuilding MakeUFOs = new UFOEnemyShipBuilding();

            EnemyShip theGrunt = MakeUFOs.OrderTheShip("UFO");

            Console.WriteLine(theGrunt + "\n");

            EnemyShip theBoss = MakeUFOs.OrderTheShip("UFO BOSS");

            Console.WriteLine(theBoss + "\n");
        }