[Solved] Poker Game

30 $

File Name: Poker_Game.zip
File Size: 94.2 KB

SKU: [Solved] Poker Game Category: Tag:

Or Upload Your Assignment Here:


Poker GameIn my Program.cs file: Leave the statement where you create a new myDeck, but delete the simple “write all 52 cardsloop”. Leave the very last Console.ReadLine(). Create an int called howManyCards and set it to 5. We will normally play with a 5 card hand,but it’s nice to be able to make it smaller when you are debugging. So never hard code a 5 inyour program, always use this variable. Create an int balance and set it to 10. This holds how much money the player has, they start with10 dollars. Set your screen output to be some color set, we will call it the base scheme, such asoo Console.ForegroundColor = ConsoleColor.Yellow;Console.BackgroundColor = ConsoleColor.DarkBlue; Write out a statement welcoming player to the game and explain they have $10 to start, andeach turn (loop) of the game will be a $1 bet. Create a while loop that runs until the player balance is $0. Each pass thru this loop represents“playing one hand” as a turn is called in card games. In the next phase, you are going to call methods that do not yet exist! That’s ok, just write the calls. In each pass through this loop:o 2 times call a new method: myDeck.GetCards(int)(Which will later be added to your CardSet Class.) It will return an array of size “howManyCards”, filled with random cards from your deck. You can just add the next twolines of code to do this. You are creating a “hand” (an array of cards) for both the computerand the player.oo SuperCard computerHand = myDeck.GetCards(howManyCards);SuperCard playersHand = myDeck.GetCards(howManyCards); o Call a new method you will write later in this Program.cs file (it will write out the cards) DisplayHands(computerHand, playersHand);o Call a new method, CompareHands ,you will write later in this Program.cs file withthis line of code. The return value will be true if the player wins this hand, false if theylose. bool won = CompareHands(computerHand, playersHand); o Then o let the player know if they won or lost (based on that bool “won”) what their new balance is, and have them click the “Enter” key to play another hand.If their balance is zero, tell them they lost, and exit the loop. End with thatConsole.ReadLine() so that the screen doesn’t disappear. Go to your CardSet class, and implement the GetCards(int) methodo public SuperCard GetCards(int number)o It picks number cards (the number you passed in) at random from the your CardArrayand returns them as an array.o You will need to instantiate the Random class, do that at the very top of the CardSetclass, right after the line where you defined the CardArray, treating it like another publicfield. (By putting it there, your random numbers will correctly flow continuously,whereas if you create Random just inside the GetCards method, you will keep re-startingthe Random sequence, and every time you play the game will look the same.)o For this stage of the project, you can reuse the same card. For example, it’s ok if a handhas 2 or 3 Jack of Diamonds. We will fix that in the next phase of the project. Now go back Program.cs and implement the missing DisplayHands method, which iso DisplayHands(computerHand, playersHand);o Start by writing a line to say this is the computers hand, and then loop through thecomputerHand array and call each member’s Display() method.o Reset the console color scheme back to your base setting.o Then write a line to say this is the player’s hand, and then loop through the playersHandarray and call each member’s Display() method.o Lastly, reset the console color scheme back to your base setting. go to your SuperClass Class and add an abstract Display method public abstract void Display();o Then go to each of your 4 card classes and implement an override Display method. I’llgive them to you here: public override void Display(){// Code to Display a club card…Console.BackgroundColor = ConsoleColor.White;Console.ForegroundColor = ConsoleColor.Blue;Console.WriteLine(cardsRank + " of " + _cardsuit + "s ♣");Console.ResetColor();}public override void Display(){// Code to Display a diamond card…Console.BackgroundColor = ConsoleColor.White;Console.ForegroundColor = ConsoleColor.DarkRed;Console.WriteLine(cardsRank + " of " + _cardsuit + "s ♦");Console.ResetColor(); }public override void Display(){// Code to Display a heart card…Console.BackgroundColor = ConsoleColor.White;Console.ForegroundColor = ConsoleColor.Red;Console.WriteLine(cardsRank + " of " + _cardsuit + "s ♥");Console.ResetColor();}public override void Display(){// Code to Display a Spade card…Console.BackgroundColor = ConsoleColor.White;Console.ForegroundColor = ConsoleColor.Black;Console.WriteLine(cardsRank + " of " + _cardsuit + "s ♠");Console.ResetColor();} Finally, implement the last missing method in Program.cs, CompareHandso It needs to have passed in to it as arguments both the computer and the player’s handarrays.o For now, just add up the int value of the rank of each card in the handso If the player’s total is greater than the computers, return a true, which means the player wono If the player’s total is less than or equal to the computers, return a false At this point, I should have a working game.If you are using Windows 10, you might have to go to the command windows properties and set them to“legacy” console to get the small card icons to show up. Right click on the small icon in the upper left of the console window. Here are 2 screen shots: Initial screen After typing enter the first time.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] Poker Game
30 $