public Competition(int doorsCount)
        {
            if (doorsCount < 3)
            {
                throw new ArgumentOutOfRangeException("The number of doors must be at least 3.");
            }
            else if (doorsCount > int.MaxValue)
            {
                throw new ArgumentOutOfRangeException();
            }

            // Start a competition
            Stage      = new Stage(doorsCount);
            Competitor = new Competitor();

            // Competitor picks a door
            Competitor.PickADoor(Stage);
        }
Exemple #2
0
        public void Start()
        {
            // Competition repeat
            for (int i = 0; i < Count; i++)
            {
                Stage      stage      = new Stage(DoorsCount);
                Competitor competitor = new Competitor();

                competitor.PickADoor(stage);

                // If the car is behind the picked door, increase staying wins, else increase changing wins
                if (competitor.PickedDoor.Number == stage.CarDoorNumber)
                {
                    Statistics.WinningCountWhenStayOnThePickedDoor++;
                }
                else
                {
                    Statistics.WinningCountWhenChangeThePickedDoor++;
                }
            }
        }