//Excecutes a unit test of class Deck. static void testDeck() { //Creates a deck and prints out the first 20 cards dealt. Console.WriteLine("\nTest Deck:"); Deck deck = new Deck(); for (int i = 0; i < 20; i++) { Card newcard = deck.deal(); Console.WriteLine(newcard.ToString()); } Console.WriteLine(); //Test the collectCardsFromPlayers method, and print out the discard pile. Hand newHand = new Hand(); for (int i = 0; i < 3; i++) { newHand.add(deck.deal()); } deck.collectCardsFromPlayers(newHand.giveCardsBackToDealer()); Console.WriteLine("Test collecting cards from players/adding cards to discard pile: "); foreach (Card c in deck.discardPile) { Console.WriteLine(c.ToString()); } Console.WriteLine("(The above cards were sucsessfully dealt, and recieved by the dealer, and added to the discard pile.)"); }
/// <summary> /// This method returns the hands of the guest player/house player to the Dealer's /// discard pile. It is done at the end of every sucsessful round or bust. /// </summary> /// <param name="guestHand">The guest's current hand.</param> /// <param name="houseHand">That house's current hand.</param> /// <param name="d">The deck being used.</param> public static void playersGiveTheirCardsBack(Hand guestHand, Hand houseHand, Deck d) { d.collectCardsFromPlayers(guestHand.giveCardsBackToDealer()); d.collectCardsFromPlayers(houseHand.giveCardsBackToDealer()); }
//Excecutes a unit test of class Hand. static void testHand() { Console.WriteLine("\nTest Hand:"); Deck deck = new Deck(); Hand currentHand = new Hand(); for (int i = 0; i < 2; i++) { currentHand.add(deck.deal()); } Console.WriteLine(currentHand.ToString()); //Test the hand score. Console.WriteLine("\nTest Hand Score:"); Console.WriteLine(currentHand.BJscore()); //Test for the first card Dealt. Console.WriteLine("\nTest first card dealt:"); Console.WriteLine(currentHand.firstCardDealt().ToString()); //Test for giving cards back to dealer. Console.WriteLine("\nTest Giving cards to dealer (end of round action): "); foreach (Card c in currentHand.giveCardsBackToDealer()) { Console.WriteLine(c.ToString()); } Console.WriteLine("(The above cards have been sucsessfully returned to the dealer.)"); //NO TEST FOR THE REMOVE METHOD, AS IT IS NOT USED IN MY PROGRAM }