コード例 #1
0
        protected override EnemyShip MakeEnemyShip(string typeOfShip)
        {
            EnemyShip theEnemyShip = null;

            if (typeOfShip.Equals("UFO"))
            {
                IEnemyShipFactory shipPartsFactory = new UFOEnemyShipFactory();
                theEnemyShip = new UFOEnemyShip(shipPartsFactory);
                theEnemyShip.SetName("UFO Grunt Ship");
            }
            else if (typeOfShip.Equals("UFO BOSS"))
            {
                IEnemyShipFactory shipPartsFactory = new UFOBossEnemyShipFactory();
                theEnemyShip = new UFOBossEnemyShip(shipPartsFactory);
                theEnemyShip.SetName("UFO Boss Ship");
            }

            return(theEnemyShip);
        }
コード例 #2
0
        protected override EnemyShip MakeEnemyShip(ShipType typeOfShip)
        {
            EnemyShip theEnemyShip = null;

            switch (typeOfShip)
            {
            case ShipType.Ufo:
                EnemyShipFactory shipPartsFactory = new UFOEnemyShipFactory();
                theEnemyShip      = new UFOEnemyShip(shipPartsFactory);
                theEnemyShip.Name = "Ufo Grunt Ship";
                break;

            case ShipType.UfoBoss:
                shipPartsFactory  = new UFOBossEnemyShipFactory();
                theEnemyShip      = new UFOEnemyShip(shipPartsFactory);
                theEnemyShip.Name = "Ufo Boss Ship";
                break;

            default:
                break;
            }

            return(theEnemyShip);
        }