Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Card Shuffling
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { 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; } } public 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; } } }
run
|
edit
|
history
|
help
0
Hi
new
Intuit // C# // listing_4.7 (case // calculator)
Jp-trize
database exterior 0.1
C# first code
Test equality...1
Main5
6. Parallelism: threads
radix sort