I am currently working on creating a card shuffler in C# and working on the Deck class now in which I want to have these 3 public methods, I currently have formed the class program and the public card class, but I'm a bit stuck on how I could start off on these 3 in Deck, just any tips about it would help. These are the 3 public methods I want to put in the Deck class
InitStandardDeck - Which populates a deck with the standard 52 cards. The cards should also be shuffled so they are in random order
DealHand - Which randomly deals 2 cards from the deck. The deck should operate like a standard deck in the sense that once those cards are dealt they are removed from the deck.
DrawACard - randomly selects 1 card from the deck. This also should operate like a standard deck in the sense that once the card is dealt it is removed form the deck.
This is the code I have so far Thank you in advance.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
Deck deck = new Deck();
deck.InitStandardDeck();
bool decided = false;
do
{
for (int i = 0; i < 100; i++)
{
List<Card> hand = deck.DealHand();
Console.Write("Hand: ");
foreach (Card c in hand)
{
Console.Write(c.GetDisplayName());
}
Console.Write("\n");
Card card = deck.DrawACard();
Console.Write("Card: ");
Console.Write(card.GetDisplayName());
Console.Write(card.Value);
Console.Write("\n");
}
Console.WriteLine("Play again? (y or n)");
string playerChoice = Console.ReadLine();
if (playerChoice.Contains("n"))
{
decided = true;
}
} while (!decided);
}
}
public class Card
{
private string m_displayName;
private SUIT m_suit;
public int Value { get; private set; }
public enum SUIT
{
Hearts,
Clubs,
Dimonds,
Spades
}
public Card(string name, SUIT suit, int value)
{
m_displayName = name;
m_suit = suit;
Value = value;
}
public string GetDisplayName()
{
return "[" + m_displayName + " of " + m_suit.ToString() + "]";
}
}
public class Deck
{
}
}