Chapter 10 page 268 Client application card deck
1using System;
2using System.Collections.Generic;
3using System.Text;
4using Ch10CardLib;
5
6namespace Ch10CardClient
7{
8 class Program
9 {
10 static void Main(string[] args)
11 {
12 Deck myDeck = new Deck();
13 myDeck.Shuffle();
14 for (int i = 0; i < 52; i++)
15 {
16 Card tempCard = myDeck.GetCard(i);
17 Console.Write(tempCard.ToString());
18 if (i != 51)
19 Console.Write(", ");
20 else
21 Console.WriteLine();
22 }
23 Console.ReadKey();
24 }
25 }
26}
public Card GetCard(int cardNum)
{
if (cardNum >= 0 && cardNum <= 51)
return cards[cardNum];
else
throw (new System.ArgumentOutOfRangeException("cardNum", cardNum, "Value must be between 0 and 51."));
}
on line 16 Card tempCard = myDeck.GetCard(i);
GetCard return cards[cardNum]
how do you assign value of cards[cardNum] to tempCard? isn't tempCard is the variable type of Card?
|