コード例 #1
0
ファイル: TDeck.cs プロジェクト: hornoo/IN710hornerb1
 public void SortHands(THand[] handArray)
 {
     for (int i = 0; i < 4; i++)
     {
         handArray[i].sortHand();
     }
 }
コード例 #2
0
ファイル: TDeck.cs プロジェクト: hornoo/IN710hornerb1
        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
ファイル: TDeck.cs プロジェクト: hornoo/IN710hornerb1
        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
ファイル: Form1.cs プロジェクト: lifengdai/IN710dail3
        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
ファイル: Form1.cs プロジェクト: lifengdai/IN710dail3
 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];
 }