예제 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            //Card c = new Card(); forbidden


            Deck deck = new Deck();

            deck.Shuffle();
            deck.Shuffle(5);

            List <Card> katiesHand = new List <Card>();
            List <Card> irvingHand = new List <Card>();

            for (int i = 0; i < 5; i++)
            {
                katiesHand.Add(deck.DealOne());
                irvingHand.Add(deck.DealOne());
            }
            Console.WriteLine("Katies Hand");
            foreach (Card c in katiesHand)
            {
                Console.Write(c + " ");
            }
        }
예제 #2
0
        private static void DealCards(Deck deck)
        {
            List <Card> hand1 = new List <Card>();
            List <Card> hand2 = new List <Card>();
            int         count = 0;

            for (Card card = deck.DealOne(); card != null; card = deck.DealOne())
            {
                count++;
                if (count > 10)
                {
                    break;
                }

                if (count % 2 == 1)
                {
                    hand1.Add(card);
                }
                else
                {
                    hand2.Add(card);
                }
            }

            if (hand2.Count < 5)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Not enough cards in the deck for two hands!");
                return;
            }

            // Print the hands

            Console.WriteLine();
            Console.WriteLine("*********************");
            Console.WriteLine("*** Player 1 Hand ***");
            Console.WriteLine("*********************");
            PrintHand(hand1);

            Console.WriteLine();
            Console.WriteLine("*********************");
            Console.WriteLine("*** Player 2 Hand ***");
            Console.WriteLine("*********************");
            PrintHand(hand2);
        }
예제 #3
0
        static void Main(string[] args)
        {
            // Default output encoding (character set) is ASCII
            // Set it to Unicode so we can display card sysbols
            Console.OutputEncoding  = System.Text.Encoding.UTF8;
            Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            // Let the user keep doing this until the cows come home
            while (true)
            {
                // Clear the screen
                Console.Clear();


                // Take the shrink-wrap off of a new deck of cards
                Deck deck = new Deck();

                // Shuffle the deck
                deck.Shuffle();

                // Deal two hands
                List <Card> player1Cards = new List <Card>();
                List <Card> player2Cards = new List <Card>();

                for (int i = 1; i <= 5; i++)
                {
                    player1Cards.Add(deck.DealOne());
                    player2Cards.Add(deck.DealOne());
                }

                // Display the two hands
                Console.WriteLine("Player 1:");
                DisplayHand(player1Cards);
                Console.WriteLine();
                Console.WriteLine("Player 2:");
                DisplayHand(player2Cards);

                Console.Write("\nType q to Quit.");
                if (Console.ReadLine().ToLower() == "q")
                {
                    break;
                }
            }
        }
예제 #4
0
        static void Main(string[] args)
        {
            Deck deck = new Deck();

            for (int i = 1; i <= 52; i++)
            {
                Card topCard = deck.DealOne();
                Console.WriteLine($"{topCard.FaceValue} of {topCard.Suit} - {topCard.Symbol}");
            }
        }
예제 #5
0
        static void Main(string[] args)
        {
            Card firstCard = new Card(8, "Hearts", true);

            if (firstCard.isFaceUp)
            {
                Console.WriteLine($"The card you picked is the {firstCard.faceValue} of {firstCard.suit} it is a {firstCard.Color} card.");
            }
            else
            {
                Console.WriteLine("Hey, are you trying to cheat?");
            }

            Card secondCard = new Card(4, "Diamonds");

            if (secondCard.isFaceUp)
            {
                Console.WriteLine($"The card you picked is the {secondCard.faceValue} of {secondCard.suit}");
            }
            else
            {
                Console.WriteLine("Hey, are you trying to cheat?");
            }

            secondCard.Flip();

            if (secondCard.isFaceUp)
            {
                Console.WriteLine($"The card you picked is the {secondCard.faceValue} of {secondCard.suit}");
            }
            else
            {
                Console.WriteLine("Hey, are you trying to cheat?");
            }

            // Let's work with a deck
            Deck deck = new Deck();

            for (int i = 0; i < deck.numberOfCardsInDeck; i++)
            {
                Card dealtCard = deck.DealOne();
                dealtCard.Flip(false);
                Console.WriteLine($"The card you dealt is the {dealtCard.faceValue} of {dealtCard.suit}");
            }
            Console.WriteLine();
            Console.WriteLine("Shuffling");
            deck = new Deck();
            deck.Shuffle();
            for (int i = 0; i < deck.numberOfCardsInDeck; i++)
            {
                Card dealtCard = deck.DealOne();
                dealtCard.Flip(false);
                Console.WriteLine($"The card you dealt is the {dealtCard.faceValue} of {dealtCard.suit}");
            }
        }
예제 #6
0
        static void Main(string[] args)
        {
            // Default output encoding (character set) is ASCII
            // Set it to Unicode so we can display card sysbols
            Console.OutputEncoding = System.Text.Encoding.UTF8;

            // Let the user keep doing this until the cows come home
            while (true)
            {
                // Clear the screen
                Console.Clear();


                // Take the shrink-wrap off of a new deck of cards
                Deck deck = new Deck();

                // Shuffle the deck
                deck.Shuffle();

                // Deal two hands


                // Display the two hands
                int count = 0;
                for (Card card = deck.DealOne(); card != null; card = deck.DealOne())
                {
                    Console.WriteLine(card.Title);
                    count++;
                }

                Console.WriteLine($"There were {count} cards in the deck");

                Console.Write("\nType q to Quit.");
                if (Console.ReadLine().ToLower() == "q")
                {
                    break;
                }
            }
        }
예제 #7
0
        static void Main(string[] args)
        {
            Deck deck = new Deck();

            // Default output encoding (character set) is ASCII
            // Set it to Unicode so we can display card sysbols
            Console.OutputEncoding = System.Text.Encoding.UTF8;

            for (int i = 1; i <= 52; i++)
            {
                Card topCard = deck.DealOne();

                Console.WriteLine($"{topCard.FaceValue} of {topCard.Suit} - {topCard.Symbol}");
            }

            Console.ReadLine();
        }
예제 #8
0
        static private void DealCards(Deck deck)
        {
            // Deal two hands of five cards each
            List <Card> hand1 = new List <Card>();
            List <Card> hand2 = new List <Card>();

            for (int i = 1; i <= 10; i++)
            {
                Card card = deck.DealOne();
                if (card == null)
                {
                    Console.WriteLine("Not enough cards in the deck!");
                    return;
                }

                if (i % 2 == 1)
                {
                    hand1.Add(card);
                }
                else
                {
                    hand2.Add(card);
                }
            }

            // Print the hands

            Console.WriteLine();
            Console.WriteLine("**************");
            Console.WriteLine("** Player 1 **");
            Console.WriteLine("**************");
            foreach (Card card in hand1)
            {
                Console.WriteLine(card.CardName);
            }

            Console.WriteLine();
            Console.WriteLine("**************");
            Console.WriteLine("** Player 2 **");
            Console.WriteLine("**************");
            foreach (Card card in hand2)
            {
                Console.WriteLine(card.CardName);
            }
        }
예제 #9
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            //class for deck
            //collection of cards
            //deal()
            //shuffle()
            //Card aceOfSpades = new Card("Spades", 1);
            //string faceValue = aceOfSpades.FaceValue;

            //static property
            //string clubs = Card.suits[0];

            Deck deckOfCards = new Deck();
            Card firstCard   = deckOfCards.DealOne();

            firstCard = firstCard;
            Console.WriteLine(firstCard.Display());
        }