Example #1
0
        /// <summary>
        ///
        /// Initialises a board consisting of a mix of Ordinary Squares,
        ///     Bad Investment Squares and Lottery Win Squares.
        /// The board has two 'non-board' squares:
        ///     a start square; and
        ///     a finish square.
        ///     This is to comply with the Hare and Tortoise requirements.
        /// The start square is to be used for initialisation, play is not yet on the board.
        /// The finish square is to be used for termination, players cannot move past this square.
        /// Pre:  none
        /// Post: board is constructed with each
        /// </summary>
        public static void SetUpBoard()
        {
            // Create the start square
            squares[START_SQUARE_NUMBER] = new Square(START_SQUARE_NUMBER, "Start");

            // Create the 40 squares which make up the board
            // some of the squares will be LotteryWinSquares,
            // others will be BadInvestmentsSquares
            // with most being just ordinary squares
            for (int i = 1; i < FINISH_SQUARE_NUMBER; i++)
            {
                if (i % 10 == 0)
                {
                    squares[i] = new LotteryWinSquare(i, "LotteryWin");
                }
                else if (i % 5 == 0)
                {
                    squares[i] = new BadInvestmentSquare(i, "BadInvestment");
                }
                else
                {
                    squares[i] = new Square(i, "Ordinary");
                } // end if
            }     // end for

            //Create the finish square
            squares[FINISH_SQUARE_NUMBER] = new Square(FINISH_SQUARE_NUMBER, "Finish");
        } // end SetUpBoard
Example #2
0
 /// <summary>
 /// Parameterless Constructor
 /// Initialises a board consisting of a mix of Ordinary Squares,
 ///     Bad Investment Squares and Lottery Win Squares.
 /// The board has two 'non-board' squares:
 ///     a start square; and
 ///     a finish square.
 ///     This is to comply with the Hare and Tortoise requirements.
 /// The start square is to be used for initialisation, play is not yet on the board.
 /// The finish square is to be used for termination, players cannot move past this square.
 /// Pre:  none
 /// Post: board is constructed
 /// </summary>
 public Board()
 {
     //fill all sqares
     for (int i = 0; i < squares.Length; i++)
     {
         Square square;
         if (i == START_SQUARE_NUMBER)
         {
             square = new Square(this, i, "Start");
         }
         else if (i == FINISH_SQUARE_NUMBER)
         {
             square = new Square(this, i, "Finish");
         }
         else
         {
             if (i % 10 == 0) //check squre is lotteryWinSquare
             {
                 square = new LotteryWinSquare(this, i, (i + 1).ToString());
             }
             else
             {
                 if (i % 5 == 0) //check sqare is lose
                 {
                     square = new BadInvestmentSquare(this, i, (i + 1).ToString());
                 }
                 else
                 {
                     square = new Square(this, i, (i + 1).ToString());
                 }
             }
         }
         squares[i] = square;
     }
 } // end Board
Example #3
0
        private Square[] squares = new Square[NUMBER_OF_SQUARES + 2]; // The array of squares.

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Parameterless Constructor
        /// Initialises a board consisting of a mix of Ordinary Squares,
        ///     Bad Investment Squares and Lottery Win Squares.
        /// The board has two 'non-board' squares:
        ///     a start square; and
        ///     a finish square.
        ///     This is to comply with the Hare and Tortoise requirements.
        /// The start square is to be used for initialisation, play is not yet on the board.
        /// The finish square is to be used for termination, players cannot move past this square.
        /// Pre:  none
        /// Post: board is constructed
        /// </summary>
        public Board()
        {
            //fill all squares
            for (int i = 0; i < squares.Length; i++)
            {
                Square square;
                if (i == START_SQUARE_NUMBER)
                {
                    square = new Square(this,i,"Start");
                }
                else if (i == FINISH_SQUARE_NUMBER)
                {
                    square = new Square(this,i,"Finish");
                }
                else
                {
                    if (i % 10 == 0) //check squre is lotteryWinSquare
                    {
                        square = new LotteryWinSquare(this, i, (i + 1).ToString());
                    }
                    else
                    {
                        if (i % 5 == 0) //check sqare is lose
                        {
                            square = new BadInvestmentSquare(this, i, (i + 1).ToString());
                        }
                        else
                        {
                            square = new Square(this, i, (i + 1).ToString());
                        }
                    }

                }
                squares[i] = square;
            }
        }