So, I took a stab at the ole C# Card Shuffle. I wanted to create my own genuine solution rather than copy someone else's. Any advice?
public class Program
{
enum Suit
{
Hearts,
Diamonds,
Clubs,
Spades
}
class Deck
{
public List<Card> Cards { get; set; }
public Deck()
{
Cards = new List<Card>();
foreach (Suit suit in Enum.GetValues(typeof(Suit)))
{
for (int y = 2; y < 11; y++)
{
Cards.Add(new Card(suit, y.ToString()));
}
Cards.Add(new Card(suit, "A"));
Cards.Add(new Card(suit, "J"));
Cards.Add(new Card(suit, "Q"));
Cards.Add(new Card(suit, "K"));
}
}
}
class Card
{
Suit suite { get; set; }
string value { get; set; }
public Card(Suit s, string v)
{
suite = s;
value = v;
}
}
static void Main(string[] args)
{
Deck myDeck = new Deck();
List<Card> shuffleDeck = new List<Card>();
Random r = new Random();
int p = 0;
while (myDeck.Cards.Count > 0)
{
p = r.Next(0, myDeck.Cards.Count);
shuffleDeck.Add(myDeck.Cards[p]);
myDeck.Cards.Remove(myDeck.Cards[p]);
}
myDeck.Cards = shuffleDeck;
}
}