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+" of " + card.suit + " "
if (card.pips==11)
Console.Write("Jack of " + card.suit + " "
if (card.pips==12)
Console.Write("Queen of " + card.suit + " "
if (card.pips==13)
Console.Write("King of " + card.suit + " "
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("Player1"
string checker1 = cards.ToString();
QueueCards PlayerA = new QueueCards();
PlayerA.CardQueue(cards);
Player1.Enqueue(checker1);
}
if (cards%2!=0)
{
Console.WriteLine("Player2"
string checker2 = cards.ToString();
Player2.Enqueue(checker2);
}
Console.WriteLine(Player1.Count);
Console.WriteLine(Player2.Count);
}
}
}
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+" of " + card.suit + " "
if (card.pips==11)
Console.Write("Jack of " + card.suit + " "
if (card.pips==12)
Console.Write("Queen of " + card.suit + " "
if (card.pips==13)
Console.Write("King of " + card.suit + " "
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("Player1"
string checker1 = cards.ToString();
QueueCards PlayerA = new QueueCards();
PlayerA.CardQueue(cards);
Player1.Enqueue(checker1);
}
if (cards%2!=0)
{
Console.WriteLine("Player2"
string checker2 = cards.ToString();
Player2.Enqueue(checker2);
}
Console.WriteLine(Player1.Count);
Console.WriteLine(Player2.Count);
}
}
}