Example #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
        /// create a hand of dominoes from the boneyard based on number of players switch statement with loop?
        /// </summary>
        /// <param name="by"></param>
        /// <param name="numPlayers"></param>
        public Hand(BoneYard by, int numPlayers)
        {
            List <Domino> handOfDominos = new List <Domino>();

            if (numPlayers == 2 | numPlayers == 3 | numPlayers == 4)
            {
                for (int i = 0; i <= 10; i++)
                {
                    handOfDominos.Add(by.Draw());
                }
            }
            else if (numPlayers == 5 | numPlayers == 6)
            {
                for (int i = 0; 0 < 9; i++)
                {
                    handOfDominos.Add(by.Draw());
                }
            }
            else
            {
                for (int i = 0; 0 < 9; i++)
                {
                    handOfDominos.Add(by.Draw());
                }
            }
        }
Example #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>
        public Hand(BoneYard by, int numPlayers)
        {
            Empty         = new EmptyHandler(HandleEmpty);
            handOfDominos = new List <Domino>();
            int numDominos;

            switch (numPlayers)
            {
            case 2:
            case 3:
            case 4:
                numDominos = 10;
                break;

            case 5:
            case 6:
                numDominos = 9;
                break;

            case 7:
            case 8:
                numDominos = 7;
                break;

            default:
                numDominos = 5;
                break;
            }
            for (int i = 0; i < numDominos; i++)
            {
                handOfDominos.Add(by.Draw());
            }
        }
Example #3
0
        /// <summary>
        /// Creates a hand of dominos from the boneyard.-switch statement and a for loop
        /// 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)
        {
            int numDominoes = 0;

            switch (numPlayers)
            {
            case 2:
            case 3:
            case 4:
                numDominoes = 10;
                break;

            case 5:
            case 6:
                numDominoes = 9;
                break;

            case 7:
            case 8:
                numDominoes = 7;
                break;
            }
            for (int i = 0; i < numDominoes; i++)
            {
                this.Add(by.Draw());
            }
        }
Example #4
0
        /// <summary>
        /// Draw - This will reach out to the boneyard and grab a domino
        /// </summary>
        public Domino Draw(BoneYard by)
        {
            Domino d = by.Draw();

            this.Add(d);
            return(d);
        }
Example #5
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)
        {
            hand = new List <Domino>();
            int handSize;

            switch (numPlayers)
            {
            case 2:
            case 3:
            case 4:
                handSize = 10;
                while (handSize > 0)
                {
                    hand.Add(by.Draw());
                    handSize--;
                }
                break;

            case 5:
            case 6:
                handSize = 9;
                while (handSize > 0)
                {
                    hand.Add(by.Draw());
                    handSize--;
                }
                break;

            case 7:
            case 8:
                handSize = 7;
                while (handSize > 0)
                {
                    hand.Add(by.Draw());
                    handSize--;
                }
                break;

            default:
                throw new ArgumentException("must hav 2-8 players");
            }
        }
Example #6
0
        /// <summary>
        /// Draws a domino from the boneyard and adds it to the hand
        /// </summary>
        /// <param name="by"></param>
        ///
        // call the  draw method from the boneyard and then add that to the hand. boom done
        public void Draw(BoneYard by)
        {
            Domino d = new Domino();

            if (by.IsEmpty())
            {
                return; //should probably throw exception.
            }
            else
            {
                handofDominos.Add(by.Draw());
            }
        }
Example #7
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());
         }
     }
 }
Example #8
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());
 }
Example #9
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);
        }
Example #10
0
        public void Draw(BoneYard by)
        {
            Domino d = by.Draw();

            this.add(d);
        }
Example #11
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());
Example #12
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());
 }