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 if (typeOfShip.Equals("UFO")) { EnemyShipFactory shipPartsFactory = new UFOEnemyShipFactory(); theEnemyShip = new UFOEnemyShip(shipPartsFactory); theEnemyShip.setName("UFO Grunt Ship"); } else // 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 if (typeOfShip.Equals("UFO BOSS")) { EnemyShipFactory shipPartsFactory = new UFOBossEnemyShipFactory(); theEnemyShip = new UFOBossEnemyShip(shipPartsFactory); theEnemyShip.setName("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); }
public EnemyShip orderTheShip(ShipType typeOfShip) { EnemyShip theEnemyShip = MakeEnemyShip(typeOfShip); theEnemyShip.MakeShip(); theEnemyShip.DisplayEnemyShip(); theEnemyShip.FollowHeroShip(); theEnemyShip.EnemyShipShoots(); return(theEnemyShip); }
public EnemyShip orderShip(ShipType type) { EnemyShip ship = MakeEnemyShip(type); ship.MakeShip(); ship.DisplayShip(); ship.FollowHeroShip(); ship.Shoot(); return(ship); }
private static void Main(string[] args) { EnemyShipBuilding <ShipType> MakeUfos = new UFOEnemyShipBuilding(); EnemyShip theGrunt = MakeUfos.orderTheShip(ShipType.Ufo); Console.WriteLine(theGrunt.Name); EnemyShip theBoss = MakeUfos.orderTheShip(ShipType.UfoBoss); Console.WriteLine(theBoss.Name); }
// Make Ship varies per ship type... protected override EnemyShip MakeEnemyShip(ShipType type) { EnemyShip ship = null; if (type == ShipType.UFO) { IEnemyShipFactory factory = new UFOEnemyShipFactory(); ship = new UFOEnemyShip(factory); ship.name = "UFO"; } return(ship); }
static void Main() { // 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"); Console.ReadLine(); }
protected override EnemyShip MakeEnemyShip(string typeOfShip) { EnemyShip theEnemyShip = null; if (typeOfShip.Equals("UFO")) { IEnemyShipFactory shipPartsFactory = new UfoEnemyShipFactory(); theEnemyShip = new UfoEnemyShip(shipPartsFactory); theEnemyShip.Name = "UFO Grunt Ship"; } else if (typeOfShip.Equals("UFO BOSS")) { IEnemyShipFactory shipPartsFactory = new UfoBossEnemyShipFactory(); theEnemyShip = new UfoBossEnemyShip(shipPartsFactory); theEnemyShip.Name = "UFO Boss Ship"; } return(theEnemyShip); }