For C# Programming GUI can I get pictures of how to complete it with the code? N
ID: 3686209 • Letter: F
Question
For C# Programming GUI can I get pictures of how to complete it with the code?
NOT A CONSOLE CODE BUT A GUI CODE WITH PICTURES
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:
Explanation / Answer
using System;
/*Class decleration*/
class GWar
{
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();
/*Main method*/
static void Main()
{
/*records total points for computer*/
int totalComputer = 0;
/*same for player*/
int totalPlayer = 0;
FillDeck();
Console.Clear();
/*LOOP*/
for(int m = 0; m < 26; m++)
{
string computerSuit;
int computer = SelectCard(out computerSuit) - 1;
string playerSuit;
int player = SelectCard(out playerSuit) - 1;
/*Condition*/
if (computer > player)
{
totalComputer += 2;
}
else if (computer < player)
{
totalPlayer += 2;
}
else
{
totalComputer += 1;
totalPlayer += 1;
}
Console.WriteLine("Deal # {0}", m + 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 m = 0; m < 52; m++)
{
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[m] = num;
break;
}
}
}
}
static int SelectCard(out string suit)
{
int num = deck[lastCardIndex];
lastCardIndex++;
suit = suits[(num - 1) % 4];
return (num - 1) / 4 + 1;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.