Beispiel #1
0
 public void DealHand()
 {
     try
     {
         Clear();
         AddRange(Deck.Deal(5));
     }
     catch (ArgumentNullException ex)
     {
         Console.WriteLine($"Error: Insufficient cards in the deck! {ex.Message}");
     }
     catch (Exception ex)
     {
         Console.WriteLine($"Unknown error: {ex.Message}");
     }
 }
        static void Main(string[] args)
        {
            Deck deck = new Deck();

            deck.Shuffle();

            Hand hand = new Hand();

            for (int i = 0; i < 5; i++)
            {
                Card card = deck.Deal();
                hand.PickUp(card);
            }

            Console.WriteLine(hand);

            IHandEvaluatorChainFactory factory = new HandEvaluatorChainFactory();
            IHandEvaluator             chain   = factory.Create();

            // TODO: Print hand evalution result to the console
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Deck deck = new Deck();

            deck.Shuffle();

            Hand hand = new Hand();

            for (int i = 0; i < 5; i++)
            {
                Card card = deck.Deal();
                hand.PickUp(card);
            }

            Console.WriteLine(hand);

            IHandEvaluatorChainFactory factory = new HandEvaluatorChainFactory();
            IHandEvaluator             chain   = factory.Create();

            Console.WriteLine($"Hand evaluation of {hand} is {chain.Evaluate(hand)}");
        }
Beispiel #4
0
        static void Main()
        {
            Hand[] hands = new Hand[10];
            Deck d = new Deck();
            d.Shuffle();

            for (int i = 0; i < hands.Length; i++)
            {
                hands[i] = new Hand();
            }

            for (int cardCount = 0; cardCount < 5; cardCount++)
            {
                foreach (Hand t in hands)
                {
                    t.Add(d.Deal());
                }
            }

            foreach (Hand hand in hands)
            {
                Console.WriteLine("{0} ({1})", hand.Rank, hand);
            }
        }