Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For C# Programming can I get pictures of how to complete it with the code? Your

ID: 3685855 • Letter: F

Question

For C# Programming can I get pictures of how to complete it with the code?

Your program assignment Create a Game in which a standard deck of playing cards is divided between two players. Eachy player exposes a card; the player whose card has the higher value wins possession of both exposed cards. Create a computerized game of War named WarCardGame in which a standard 52- card deck is randomly divided between two players, one of which is the computer. Reveal one card from the computer and one card from the player at a time. Award two points for the the player whose card has the higher value. (For this game the king is the highest card, followed by the queen and jack, then the numbers 10 down to 2. And finally the qaace.) If the computer and player expose cards of equal value in the same turn, award one point to each. At the end of the game, all 52 cards should have been played only once, and the sum of the player’s and computer’s score will be 52. Use an array of 52 integers to store unique values for each card. Write a method named FillDeck() that places 52 unique values into this array

Example How it should look:



WAR

Explanation / Answer

Hi below i have written the code for your reference,

using System;

class War

{

static int[] deck = new int[52]; // all zero by default

static int lastCardIndex = 0;

static string[] cards = {"Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"};

static string[] suits = {"clubs", "diamonds", "hearts", "spades"};

static Random rand = new Random();

static void Main()

{

int totalComputer = 0; // records total points for computer

int totalPlayer = 0; // ditto for player

FillDeck();

Console.Clear();

  

// 26 deals

for(int i = 0; i < 26; i++)

{

string computerSuit;

int computer = SelectCard(out computerSuit) - 1;

string playerSuit;

int player = SelectCard(out playerSuit) - 1;

if (computer > player)

{

totalComputer += 2;

}

else if (computer < player)

{

totalPlayer += 2;

}

else

{

totalComputer += 1;

totalPlayer += 1;

}

Console.WriteLine("Deal # {0}", i + 1);

Console.WriteLine(" Computer has {0} of {1}", cards[computer], computerSuit);

Console.WriteLine(" Player has {0} of {1}", cards[player], playerSuit);

Console.WriteLine("Computer Score is {0}", totalComputer);

Console.WriteLine("Player Score is {0}", totalPlayer);

Console.WriteLine();

Console.ReadKey();

}

}

static void FillDeck()

{

for(int i = 0; i < 52; i++)

{

while(true)

{

int num = rand.Next(1, 53); // get number between 1 and 52 inclusive

if (Array.IndexOf(deck, num) == -1) // not already used

{

deck[i] = num;

break;

}

}

}

}

static int SelectCard(out string suit)

{

int num = deck[lastCardIndex];

lastCardIndex++;

suit = suits[(num - 1) % 4];

return (num - 1) / 4 + 1;

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote