public void CreateDeckTest() { var deck = new Deck(); Assert.IsNotNull(deck); Assert.AreEqual(52, deck.Cards.Count); }
/// <summary> /// Entry point for demo console application. /// </summary> public static void Main() { Deck deck = new Deck(); while (deck.NumberOfRemainingCards > 0) { Console.WriteLine(deck.deal_one_card().ToString()); } Console.WriteLine("\r\nShuffling...\r\n"); deck.shuffle(); while (deck.NumberOfRemainingCards > 0) { Console.WriteLine(deck.deal_one_card().ToString()); } Console.WriteLine("\r\nTesting second implementation\r\n"); Deck_FisherYates deck2 = new Deck_FisherYates(); while (deck2.NumberOfRemainingCards > 0) { Console.WriteLine(deck2.deal_one_card().ToString()); } Console.WriteLine("\r\nShuffling...\r\n"); deck2.shuffle(); while (deck2.NumberOfRemainingCards > 0) { Console.WriteLine(deck2.deal_one_card().ToString()); } Console.WriteLine("Demo completed."); }
public void SuffleTest() { var deck = new Deck(); deck.Shuffle(); Assert.AreEqual(52, deck.Cards.Count); }
public void TestConstructor() { Deck deck = new Deck(); Assert.AreEqual(52, deck.NumberOfRemainingCards); // Ensure all suites/values are represented Array values = Enum.GetValues(typeof(FaceValue)); Array suites = Enum.GetValues(typeof(Suite)); int[] suiteCounts = new int[suites.Length]; int[] valueCounts = new int[values.Length]; while (deck.NumberOfRemainingCards > 0) { Card card = deck.deal_one_card(); suiteCounts[(int)card.Suite - 1] += 1; valueCounts[(int)card.FaceValue - 1] += 1; } // There should be 13 cards of each of the 4 suites foreach (int index in suiteCounts) { Assert.AreEqual(13, index); } // There should be 4 suites for each of the face values foreach (int index in valueCounts) { Assert.AreEqual(4, index); } }
public Hand(List<PlayerMetadata> players, Deck deck) { _deck = deck; Players = players; SpadesHaveBeenBroken = false; Tricks = new List<Trick>(); }
public void Setup() { Players = new List<PlayerMetadata>(); Players.Add(new PlayerMetadata(1, new DefaultPlayer())); Players.Add(new PlayerMetadata(1, new DefaultPlayer())); Players.Add(new PlayerMetadata(1, new DefaultPlayer())); Players.Add(new PlayerMetadata(1, new DefaultPlayer())); Deck = new Deck(); }
public void TestDeal() { Deck deck = new Deck(); Card card = deck.deal_one_card(); Assert.IsNotNull(card); while (deck.NumberOfRemainingCards > 0) { deck.deal_one_card(); } Assert.IsNull(deck.deal_one_card()); }
public void TestShuffle() { Deck deck = new Deck(); while (deck.NumberOfRemainingCards > 0) { deck.deal_one_card(); } Assert.AreEqual(0, deck.NumberOfRemainingCards); Assert.IsNull(deck.deal_one_card()); deck.shuffle(); Assert.AreEqual(52, deck.NumberOfRemainingCards); }
static void Main(string[] args) { Stack<Card>[] tableauPiles = new Stack<Card>[7]; Stack<Card>[] foundationPiles = new Stack<Card>[4]; Stack<Card> wastePile = new Stack<Card>(); Deck stockPile = new Deck(); for (int i = 0; i < foundationPiles.Length; ++i) { foundationPiles[i] = new Stack<Card>(13); } for (int i = 0; i < tableauPiles.Length; ++i) { tableauPiles[i] = new Stack<Card>(i + 1); tableauPiles[i].Push(stockPile.Pop()); } // Card waste = wastePile.Peek(); // Console.WriteLine("waste: {0} of {1}", waste.value, waste.suit); Console.WriteLine("tableau: {0}", tableauPiles.Map(pile => "\n" + pile.Peek().ToString()).Join("")); Console.ReadKey(); }
public Game() { Deck = new Deck(); ScoreSheet = new ScoreSheet(); }