Esempio n. 1
0
        /// <summary>
        /// Creates a hand of dominos from the boneyard.
        /// The number of dominos is based on the number of players
        /// 2–4 players: 10 dominoes each
        /// 5–6 players: 9 dominoes each
        /// 7–8 players: 7 dominoes each
        /// </summary>
        /// <param name="by"></param>
        /// <param name="numPlayers"></param>
        public Hand(BoneYard by, int numPlayers)
        {
            switch (numPlayers)
            {
            case 2:
            case 3:
            case 4:
                playerHand = new List <Domino>(10);
                while (Count < 10)
                {
                    Draw(by);
                }
                break;

            case 5:
            case 6:
                playerHand = new List <Domino>(9);
                while (Count < 9)
                {
                    Draw(by);
                }
                break;

            case 7:
            case 8:
                playerHand = new List <Domino>(7);
                while (Count < 7)
                {
                    Draw(by);
                }
                break;

            default:
                throw new ArgumentException("Invalid quantity of players");
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Creates a hand of dominos from the boneyard.
 /// The number of dominos is based on the number of players
 /// 2–4 players: 10 dominoes each
 /// 5–6 players: 9 dominoes each
 /// 7–8 players: 7 dominoes each
 /// </summary>
 /// <param name="by"></param>
 /// <param name="numPlayers"></param>
 ///
 //switch or other loop would work here.
 public Hand(BoneYard by, int numPlayers)
 {
     if (numPlayers == 2 || numPlayers == 3 || numPlayers == 4)
     {
         for (int d = 0; d == 10; d++)
         {
             handofDominos.Add(by.Draw());
         }
     }
     if (numPlayers == 5 || numPlayers == 6)
     {
         for (int d = 0; d == 9; d++)
         {
             handofDominos.Add(by.Draw());
         }
     }
     if (numPlayers == 7 || numPlayers == 8)
     {
         for (int d = 0; d == 7; d++)
         {
             handofDominos.Add(by.Draw());
         }
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Draws a domino from the boneyard and adds it to the hand
 /// </summary>
 /// <param name="by"></param>
 public void Draw(BoneYard by)
 {
     Add(by.Draw());
 }
Esempio n. 4
0
        /// <summary>
        /// Draws a domino from the boneyard and adds it to the hand
        /// </summary>
        /// <param name="by"></param>
        public void Draw(BoneYard by)
        {
            Domino d = by.Draw();

            handOfDominos.Add(d);
        }
Esempio n. 5
0
        public void Draw(BoneYard by)
        {
            Domino d = by.Draw();

            this.add(d);
        }
Esempio n. 6
0
 public void HandleEmpty(BoneYard b)
 {
 }
Esempio n. 7
0
 /// <summary>
 /// Draws a domino from the boneyard and adds it to the hand
 /// </summary>
 /// <param name="by"></param>
 public void Draw(BoneYard by) => hand.Add(by.Draw());
Esempio n. 8
0
 /// <summary>
 /// Draws a domino from the boneyard and adds it to the hand
 /// call draw method from boneyard
 /// </summary>
 /// <param name="by"></param>
 public void Draw(BoneYard by)
 {
     handOfDominos.Add(by.Draw());
 }