Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Someone, please make this project work. C# I have done what I can please make it work. It must use all the current code. Because

Someone, please make this project work. C# I have done what I can please make it work. It must use all the current code. Because some of it is from the example project given in the book.

These are the instructions:

Purpose: This application will function similarly to a game of poker. The program will deal out 2 five-card hands and determine what each hand contains. Program Procedures: The program will create a standard deck of 52 playing cards. It will shuffle the deck then deal 5 cards to The computer and The player. The program will evaluate what each hand has and display the cards graphically as well as printing the value of the hands (as defined below). Algorithms, Processing and Conditions: 1. The application must be implemented as a Windows C# console program. 2. There should be at least three classes (one in each class file) defined for the project. One of the classes will be called Card. Another class will be called DeckOfCards. 3. You should use a minimum of 3arrays: 1 for the deck of cards, 1 for the players hand, one for the computers hand. 4. You should display each hand graphically (using the example from Chapter 8 posted in Moodle). 5. You should use a random number to shuffle the deck. 6. The hands are evaluated as follows: a. Four of a kind (e.g. 4 Aces) b. Full House (2 of and kind and 3 of a kind in same hand) c. Flush (all 5 cards of the same suit) d. Straight (all 5 cards face values in sequence (2,3,4,5,6) e. Three of a Kind. f. 2 Pairs g. Pair Notes and Restrictions: You should add read-only properties to the Card class to get the face and suit of each card. Comments: All variables and objects must have meaningful names and should use lower camel casing. All classes, properties and methods should have meaningful names and should use upper camel casing.

class DeckOfCardsTest { static void Main(string[] args) {

Card[] compHand = new Card[5]; Card[] playerHand = new Card[5];

DeckOfCards myDeck = new DeckOfCards(); myDeck.Shuffle();

for (int i = 0; i < 5; i++) { playerHand[i] = myDeck.DealCard(); compHand[i] = myDeck.DealCard(); //Console.Write("{0,-19}", myDeck.DealCard());

//if ((i + 1) % 4 == 0) //{ // Console.WriteLine(); //} } // end of for

Console.WriteLine("Player's Hand:"); for (int i = 0; i < 5; i++) { playerHand[i].DisplayCard(1, i * 6); //Console.Write("{0,-19}", playerHand[i]); //if ((i + 1) % 4 == 0) //{ // Console.WriteLine(); //} }

Console.SetCursorPosition(0, 12); Console.WriteLine("Computer's Hand:"); for (int i = 0; i < 5; i++) { compHand[i].DisplayCard(13, i * 6); //Console.Write("{0,-19}", compHand[i]); //if ((i + 1) % 4 == 0) //{ // Console.WriteLine(); //} } Console.WriteLine(); Console.WriteLine();

} // end of Main } } //end of the main class

{ class DeckOfCards { private Card[] deck; private int currentCard; private const int NUMBER_OF_CARDS = 52; private Random randomNumbers;

public DeckOfCards() { string[] faces = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K" }; string[] suits = { "Hearts", "Diamonds", "Clubs", "Spades" }; //string[] deckOfCards = { "Hearts", "Diamonds", "Clubs", "Spades" }; my start

deck = new Card[NUMBER_OF_CARDS]; currentCard = 0; randomNumbers = new Random();

for (int count = 0; count < deck.Length; count++) { deck[count] = new Card(faces[count % 13], suits[count / 13]); }// end of for

} // end of constructor

public void Shuffle() { currentCard = 0;

for (int first = 0; first < deck.Length; first++) { int second = randomNumbers.Next(NUMBER_OF_CARDS);

Card temp = deck[first]; deck[first] = deck[second]; deck[second] = temp; } // end of for } // end of method Shuffle

public Card DealCard() { if (currentCard < deck.Length) { return deck[currentCard++]; } else { return null; } } // end of DealCard } } //end of class DeckOfCards

{ class Card { private string face; private string suit;

public Card(string cardFace, string cardSuit) { face = cardFace; suit = cardSuit; } // end of constructor

public override string ToString() { return face + " of " + suit; } // end of ToString

public void DisplayCard(int row, int col) { Console.SetCursorPosition(col, row); Console.BackgroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.Blue; Console.Write(""); Console.SetCursorPosition(col, row + 1); Console.Write(" "); if (suit == "Diamonds" || suit == "Hearts") { Console.ForegroundColor = ConsoleColor.Red; } else { Console.ForegroundColor = ConsoleColor.Black; } Console.Write(face); Console.ForegroundColor = ConsoleColor.Blue; Console.Write(" "); Console.SetCursorPosition(col, row + 2); Console.Write(" "); Console.SetCursorPosition(col, row + 3); Console.Write(" "); if (suit == "Diamonds" || suit == "Hearts") { Console.ForegroundColor = ConsoleColor.Red; } else { Console.ForegroundColor = ConsoleColor.Black; } if (suit == "Diamonds") { Console.Write(""); } if (suit == "Hearts") { Console.Write(""); } if (suit == "Spades") { Console.Write(""); } if (suit == "Clubs") { Console.Write(""); } Console.ForegroundColor = ConsoleColor.Blue; Console.Write(" "); Console.SetCursorPosition(col, row + 4); Console.Write("");

Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; }

} } //end of class Card

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions