Пример #1
0
 public void SortHands(THand[] handArray)
 {
     for (int i = 0; i < 4; i++)
     {
         handArray[i].sortHand();
     }
 }
Пример #2
0
        public string ToString(THand[] handArray)
        {
            String AllHands = "";
            for (int i = 0; i < 4; i++)
            {
                AllHands += "Player " + (i + 1) + ": \r\n";
                AllHands += handArray[i].ToString();
                AllHands += "Points: " + handArray[i].calcPoints() + "\r\n \r\n";
            }

            return AllHands;
        }
Пример #3
0
        public void DealCards(THand[] handArray)
        {
            int cardIndex = 0;

            for (int i = 0; i < deckSize / numPlayers; i++)
            {
                for (int j = 0; j < numPlayers; j++)
                {
                    handArray[j].addCard(cards[cardIndex]);
                    cardIndex++;
                }
            }
        }
Пример #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            TDeck newDeck = new TDeck();
            THand[] fourHands = new THand[4];
            for (int i = 0; i < 4; i++)
            {
                fourHands[i] = new THand();
            }

            newDeck.ShuffleDeck();
            newDeck.DealCards(fourHands);
            //newDeck.SortHands(fourHands);
            CardBox.Text = newDeck.ToString(fourHands);
            findWinner(fourHands);
        }
Пример #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            TDeck newDeck = new TDeck();

            THand[] fourHands = new THand[4];
            for (int i = 0; i < 4; i++)
            {
                fourHands[i] = new THand();
            }

            newDeck.ShuffleDeck();
            newDeck.DealCards(fourHands);
            //newDeck.SortHands(fourHands);
            CardBox.Text = newDeck.ToString(fourHands);
            findWinner(fourHands);
        }
Пример #6
0
 private void findWinner(THand[] fourHands)
 {
     int maxPoints = 0;
     int maxPos = 0;
     bool tie = false;
     int[] allPoints = new int[4];
     int[] tiePos = new int[4];
     int numTies = 0;
     for (int i = 0; i < 4; i++)
     {
         int thisPoints = fourHands[i].calcPoints();
         allPoints[i] = thisPoints;
         if (thisPoints > maxPoints)
         {
             maxPos = i;
             maxPoints = thisPoints;
             tie = false;
             numTies = 0;
         }
         else if (thisPoints == maxPoints)
         {
             tiePos[numTies] = maxPos;
             tiePos[++numTies] = i;
             maxPos = i;
             tie = true;
         }
     }
     if (tie)
     {
         String Winner = "Player " + (tiePos[0] + 1);
         int j;
         for (j = 1; j <= numTies; j++)
         {
             Winner += ", Player " + (tiePos[j] + 1);
         }
         Winner += " are tied with " + allPoints[tiePos[j]] + " points!";
         WinnerBox.Text = Winner;
     }
     else WinnerBox.Text = "Player " + (maxPos + 1) + " wins with " + maxPoints + " points!";
     Score1.Text = "" + allPoints[0];
     Score2.Text = "" + allPoints[1];
     Score3.Text = "" + allPoints[2];
     Score4.Text = "" + allPoints[3];
 }