Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Parameters from Static Void

Status
Not open for further replies.

StuGee

Technical User
Jan 12, 2004
2
GB
I am trying to amend code to enable me to queue playing card values up so that I am able to deal them out to two plays who are then able to compare their card values.

I have been unable to pass the card vlaue from the public static void OutputCard to the static void dealcards. The codee is attached below, I have been able to pass the value but each queue is reset as I it is necessary to declare the queues within the method. Can someone please suggest how I would rectify this problem.


public static void OutputCard(Card card, int players)
{
if (card.pips<11)
Console.Write(card.pips+&quot; of &quot; + card.suit + &quot; &quot;);
if (card.pips==11)
Console.Write(&quot;Jack of &quot; + card.suit + &quot; &quot;);
if (card.pips==12)
Console.Write(&quot;Queen of &quot; + card.suit + &quot; &quot;);
if (card.pips==13)
Console.Write(&quot;King of &quot; + card.suit + &quot; &quot;);
if (players !=1)
{
DealCards(card.pips);
}
}



static void DealCards(int cards)
{
Queue Player1= new Queue();
Queue Player2= new Queue();

if (cards%2==0)
{
Console.WriteLine(&quot;Player1&quot;);
string checker1 = cards.ToString();
QueueCards PlayerA = new QueueCards();
PlayerA.CardQueue(cards);
Player1.Enqueue(checker1);
}
if (cards%2!=0)
{
Console.WriteLine(&quot;Player2&quot;);
string checker2 = cards.ToString();
Player2.Enqueue(checker2);
}
Console.WriteLine(Player1.Count);
Console.WriteLine(Player2.Count);
}
}
}
 
What's the datatype for Cards.pips?

The DealCards method wants a single integer.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top