public override Mine CreateMine(MinePower power) { Mine mineToReturn = null; if (this.createdMines.ContainsKey(power)) { mineToReturn = this.createdMines[power]; } else { switch (power) { case MinePower.One: mineToReturn = new LimpetMine(); break; case MinePower.Two: mineToReturn = new LandMine(); break; case MinePower.Three: mineToReturn = new NavelMine(); break; case MinePower.Four: mineToReturn = new NuclearMine(); break; case MinePower.Five: mineToReturn = new FatherBomb(); break; default: throw new ArgumentException(string.Format("Mine with power: {0}, does not exists YET!", power)); } this.createdMines.Add(power, mineToReturn); } return(mineToReturn); }
/// <summary> /// Abstract method that the children of this class must use to manufacture mines. /// </summary> /// <param name="power">Accepts MinePower enumeration to determine the power of the mine.</param> /// <returns>Returns an instance of IMine with the given power.</returns> public abstract IExplodable CreateMine(MinePower power);
public abstract Mine CreateMine(MinePower power);