Exemplo n.º 1
0
 public void AssignGame(int numberOfPlayers, IBonusStrategy bonusStrategy)
 {
     if (this.Free == true)
     {
         this.Game = new Game(numberOfPlayers, bonusStrategy);
     }
 }
Exemplo n.º 2
0
 public void FindEmptyLaneAndAssignGame(int numberOfPlayers, IBonusStrategy bonusStrategy)
 {
     foreach (var lane in this.lanes)
     {
         if (lane.Free == true)
         {
             lane.AssignGame(numberOfPlayers, bonusStrategy);
         }
     }
 }
Exemplo n.º 3
0
        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++;
        }
Exemplo n.º 4
0
    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;
        }
    }
Exemplo n.º 5
0
 public CalculateBonus(IBonusStrategy bonusStrategy)
 {
     _bonusStrategy = bonusStrategy;
 }