/// <summary>
 /// Rolls the two dice to determine 
 ///     the number of squares to move forward; and
 ///     moves the player's location along the board; and
 ///     obtains the effect of landing on their final square.
 /// Pre:  dice are initialised
 /// Post: the player is moved along the board and the effect
 ///     of the location the player landed on is applied.
 /// </summary>
 /// <param name="d1">first die</param>
 /// <param name="d2">second die</param>
 public void Play(Die d1, Die d2)
 {
     //######################### Code needs to be added here ##########################################
     d1 = new Die();
     d2 = new Die();
     d1.Roll();
     d2.Roll();
     Move(d1.FaceValue + d2.FaceValue);
 }
 /// <summary>
 /// Parameterless Constructor.
 /// Initialise the board, and the two dice.
 /// Pre:  none
 /// Post: the board and the objects it conatins are initialised.
 /// </summary>
 public HareAndTortoiseGame()
 {
     board = new Board();
     die1 = new Die();
     die2 = new Die();
 }
 /// <summary>
 /// Parameterless Constructor.
 /// Initialise the board, and the two dice.
 /// Pre:  none
 /// Post: the board and the objects it conatins are initialised.
 /// </summary>
 public HareAndTortoiseGame(Board gameBoard)
 {
     this.board = gameBoard;
     die1 = new Die();
     die2 = new Die();
 }
Beispiel #4
0
        } // end Player constructor

        /// <summary>
        /// Rolls the two dice to determine
        ///     the number of squares to move forward; and
        ///     moves the player's location along the board; and
        ///     obtains the effect of landing on their final square.
        /// Pre:  dice are initialised
        /// Post: the player is moved along the board and the effect
        ///     of the location the player landed on is applied.
        /// </summary>
        /// <param name="d1">first die</param>
        /// <param name="d2">second die</param>
        public void Play(Die d1, Die d2)
        {
            //######################### Code needs to be added here ##########################################
        } // end Play.
 /// <summary>
 /// Rolls the two dice to determine 
 ///     the number of squares to move forward; and
 ///     moves the player's location along the board; and
 ///     obtains the effect of landing on their final square.
 /// Pre:  dice are initialised
 /// Post: the player is moved along the board and the effect
 ///     of the location the player landed on is applied.
 /// </summary>
 /// <param name="d1">first die</param>
 /// <param name="d2">second die</param>
 public void Play(Die d1, Die d2)
 {
     d1.Roll();
     d2.Roll();
 }
 /// <summary>
 /// Parameterless Constructor.
 /// Initialise the board, and the two dice.
 /// Pre:  none
 /// Post: the board and the objects it conatins are initialised.
 /// </summary>
 public HareAndTortoiseGame(Board gameBoard)
 {
     this.board = gameBoard;
     die1       = new Die();
     die2       = new Die();
 } //end Game
Beispiel #7
0
        /// <summary>
        /// Rolls the two dice to determine 
        ///     the number of squares to move forward; and
        ///     moves the player's location along the board; and
        ///     obtains the effect of landing on their final square.
        /// Pre:  dice are initialised
        /// Post: the player is moved along the board and the effect
        ///     of the location the player landed on is applied.
        /// </summary>
        /// <param name="d1">first die</param>
        /// <param name="d2">second die</param>
        public void Play(Die d1, Die d2)
        {
            int movePoint = d1.Roll() + d2.Roll();
            int movePointAgain = d1.Roll() + d2.Roll();
            Move(movePoint);

            //once player land on the lose square, they would be subtracted $25
            if (location.Name.Equals("bad investment"))
            {
                Debit(25);
            }

            //once player land on the win square, they can add $10, and roll dice again
            else if (location.Name.Equals("lottery win"))
            {
                Credit(10);
                Move(movePointAgain);
            }// end if
        }