/** Deals a new hand from the stock. */ public abstract int DealHand(Deck stock);
/** Runs the unit test. */ public override void RunTests() { Debug.Write ("\nTesting Deck Class\n" + CardGame.ConsoleLine ('*') + "Creating test Deck...\n"); Deck stock = new Deck (); Debug.Assert (stock.NumCards == 52, "Error: There where not 52 stock!\n" + stock.ToString()); Debug.Write (stock.ToString () + "\n\nShuffling Deck...\n"); stock.Shuffle (); Debug.WriteLine ("\n\n" + stock.ToString () + "\n\nTesting DrawCard () by drawing 42 stock...\n"); for (int i = 0; i < 42; i++) Debug.Write (stock.DrawCard ().ToString () + ", "); Debug.WriteLine ("\n\nPrinting last 10 stock...\n\n" + stock.ToString () + "\n\nTesting DrawRandomCard () by drawing 5 stock...\n"); for (int i = 0; i < 5; i++) Debug.Write (stock.DrawRandomCard ().ToString () + ", "); int numLoops = 10, numExpectedNullstock = numLoops - stock.NumCards, counter = 0; Debug.WriteLine ("\n\nPrinting last " + numExpectedNullstock + " stock...\n\n" + stock.ToString () + "\n\nDrawing 10 more random stock and expecting 5 null stock...\n"); String drawnstock = ""; for (int i = 1; i <= numLoops; i++) { var tempCard = stock.DrawRandomCard (); if (tempCard != null) { Debug.WriteLine (i + ", "); drawnstock += tempCard.ToString () + ", "; } else counter++; } Debug.Assert (counter == numExpectedNullstock, "Error: There were supposed to be " + numExpectedNullstock + " null stock and got " + counter + "!\nDraw stock:\n" + drawnstock + "\n" + stock.ToString ()); Debug.Assert (stock.IsEmpty, "Error: After trying to take more stock than the stock had, the stock was not empty!"); Debug.Write ("\n\nPrinting empty Deck...\n\n" + stock.ToString () + "\n\nShuffling and printing stock...\n"); stock.Shuffle(); Debug.WriteLine (stock.ToString () + "\n\n"); Debug.WriteLine ("Done testing the Deck class.\n"); }