示例#1
0
        /** Runs the unit test. */
        public override void RunTests()
        {
            Debug.Write("Testing the BlackjackPlayer class\n" + CardGame.ConsoleLine ('*') + "\n" +
                "Creating player1 and printing ToString ()...\n");

            var player1 = new BlackjackPlayer("Player 1", 10);

            Debug.Write(player1.ToString() + "\n\n" +
                "Attempting to take away more points than the user has...\n\n");

            player1.RemovePoints(100);

            Debug.Assert(player1.NumPoints == 10, "Error! The computer took away more points than player1 had!");

            var Deck = new Deck();
            Deck.Shuffle();

            Debug.Write("Dealing hand and testing int Compare (Hand) function...\n\n");

            var player2 = new BlackjackPlayer("Player 2", 999999999);

            player1.Hand.AddCard(Deck.DrawCard(10, 3));
            player1.Hand.AddCard(Deck.DrawCard(1, 4));

            player2.Hand.AddCard(Deck.DrawCard(10, 3));
            player2.Hand.AddCard(Deck.DrawCard(5, 4));

            Debug.Write("Comparing 10 plus ace to 10 plus 5\n");

            Debug.Assert(player1.Hand.Compare(player2.Hand) > 1, "Error ! player1 had 21!");

            player1.Hand.Clear();
            player2.Hand.Clear();

            player1.Hand.AddCard(Deck.DrawCard(13, 3));
            player1.Hand.AddCard(Deck.DrawCard(7, 4));

            player2.Hand.AddCard(Deck.DrawCard(7, 3));
            player2.Hand.AddCard(Deck.DrawCard(4, 4));

            Debug.Assert(player1.HandWins(player2), "Error ! player1 had a hiter point total!");

            Debug.Write("\n\nDone testing the BlackjackPlayer class.\n\n\n");
        }
示例#2
0
        public override void NewRound()
        {
            ante = minAnte;
            pointsInThePot = 0;

            player = new BlackjackPlayer ("Dojo Jedi", 200);
            dealer = new BlackjackDealer ();

            pointsInThePot = NumPlayers * ante;

            player.RemovePoints (ante);
            dealer.RemovePoints (ante);

            Stock.RestockDeck ();

            player.DealHand (Stock);
            dealer.DealHand (Stock);
        }