public void AssignGame(int numberOfPlayers, IBonusStrategy bonusStrategy) { if (this.Free == true) { this.Game = new Game(numberOfPlayers, bonusStrategy); } }
public void FindEmptyLaneAndAssignGame(int numberOfPlayers, IBonusStrategy bonusStrategy) { foreach (var lane in this.lanes) { if (lane.Free == true) { lane.AssignGame(numberOfPlayers, bonusStrategy); } } }
public Game(int numberOfPlayers, IBonusStrategy bonusStrategy) { this.players = new List <Player>(); for (int i = 0; i < numberOfPlayers; i++) { this.players.Add(new Player()); } this.BonusStrategy = bonusStrategy; this.gameID = idGenerator++; }
public static void SimulateBowlingArena(int numberOfLanes, int numberOfGamesToBePlayed, IBonusStrategy bonusStrategy) { Alley = new Alley(numberOfLanes); while (numberOfGamesToBePlayed > 0) { int numberOfGamesThatCanBeAccomodated = Math.Min(numberOfGamesToBePlayed, numberOfLanes); for (int i = 0; i < numberOfGamesThatCanBeAccomodated; i++) { Alley.FindEmptyLaneAndAssignGame(random.Next(MinNumberOfPlayers, MaxNumberOfPlayers), bonusStrategy); } Alley.StartGamesInAllOccupiedLanes(); numberOfGamesToBePlayed = numberOfGamesToBePlayed - numberOfGamesThatCanBeAccomodated; } }
public CalculateBonus(IBonusStrategy bonusStrategy) { _bonusStrategy = bonusStrategy; }