Exemplo n.º 1
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)
 {
     d1.Roll();
     d2.Roll();
 }
Exemplo n.º 2
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)
 {
     //######################### Code needs to be added here ##########################################
     d1 = new Die();
     d2 = new Die();
     d1.Roll();
     d2.Roll();
     Move(d1.FaceValue + d2.FaceValue);
 }
Exemplo n.º 3
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
        }