Пример #1
0
        static void Main(string[] args)
        {
            var  deckOfCards = new Deck();
            char input       = '-';

            while (input != 'q')
            {
                switch (input)
                {
                case 'n':
                    deckOfCards = Deck.CreateNewDeck();
                    Console.WriteLine("New deck was created");

                    break;

                case 's':
                    Console.WriteLine("Shuffling deck...");
                    Console.WriteLine("/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\");
                    deckOfCards.ShuffleDeck();
                    Console.WriteLine("Deck is shuffled. Ready to go!");
                    break;

                case 'd':
                    Card currentCard = deckOfCards.Draw();
                    if (currentCard == null)
                    {
                        Console.WriteLine("Deck is empty. Press the n key to create another deck.");
                    }
                    else
                    {
                        Console.WriteLine($"Current card rank ** {currentCard.Rank} ** and the suit is ** {currentCard.Suit} **");
                    }

                    break;

                case 'r':
                    Console.WriteLine("Showing all cards remaining in deck. ****************************");
                    Console.WriteLine(deckOfCards.Cards.Count().ToString());
                    foreach (Card card in deckOfCards.Cards)
                    {
                        Console.WriteLine($"Current card rank ** {card.Rank} ** and the suit is ** {card.Suit} **");
                    }
                    ;
                    Console.WriteLine("Done displaying cards. ****************************");
                    break;

                default:
                    Console.WriteLine("Enter one of five keys to play the game.");
                    Console.WriteLine("q : Quit the game.");
                    Console.WriteLine("n : Create new deck.");
                    Console.WriteLine("s : Shuffle current deck.");
                    Console.WriteLine("d : Draw next card.");
                    Console.WriteLine("r : Display to console all the current cards in deck.");
                    break;
                }
                input = Console.ReadKey().KeyChar;
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            int  input  = 0;
            Deck myDeck = new Deck();
            Card myCard = new Card(Face.Ace, Suit.Clubs);

            while (input != 6)
            {
                Console.WriteLine("1. Shuffles the deck");
                Console.WriteLine("2. Draws a card from the deck");
                Console.WriteLine("3. Discards a card to the discard pile");
                Console.WriteLine("4. Prints the deck");
                Console.WriteLine("5. Prints the discard");

                input = int.Parse(Console.ReadLine());

                if (input == 1)
                {
                    myDeck.Shuffle();
                    Console.WriteLine(" ");
                    Console.WriteLine("The deck has been shuffled!");
                    Console.WriteLine(" ");
                }

                if (input == 2)
                {
                    myCard = myDeck.Draw();
                }

                if (input == 3)
                {
                    myDeck.Discard(myCard);
                    myCard = null;
                }

                if (input == 4)
                {
                    Console.WriteLine(" ");
                    Console.WriteLine("This is the deck so far: ");
                    myDeck.PrintDeck();
                }

                if (input == 5)
                {
                    Console.WriteLine(" ");

                    Console.WriteLine("This is the current discard pile: ");

                    myDeck.PrintDiscard();
                }
            }
        }
Пример #3
0
        public static void Main()
        {
            // Create a deck cards.
            Deck deck = new Deck();

            // Draw a card.
            var card = deck.Draw();

            // Show the value.
            Console.WriteLine(card.GetFullName());

            Console.ReadLine();
        }
Пример #4
0
        static void Main(string[] args)
        {
            //Create a deck object in the main program

            Deck deck = new Deck();

            // Draws a random card
            var card1 = deck.Draw();


            //shows the value of the drawn card
            Console.WriteLine($"A random card was drawn from the deck for you: {card1.GetFullName()}");
            Console.ReadLine();
        }
Пример #5
0
        static void Main(string[] args)
        {
            Console.Write("(Standard Deck) Card: ");

            //New deck object.
            Deck deck = new Deck();

            //Draws a card from the deck.
            var card = deck.Draw();

            //Prints the full name of the card that was drawn
            //from the deck to the console.
            Console.WriteLine(card.GetFullName());
            Console.ReadLine();
        }
Пример #6
0
        public static void Main()
        {
            // Create a deck cards.
            Deck deck = new Deck();

            /*
             * for (int i = 0; i < deck.Cards.Length; i++)
             * {
             *  Console.WriteLine(deck.Cards[i].GetFullName());
             * }
             */

            // Draw a card.
            Card card = deck.Draw();

            // Show the value.
            Console.WriteLine(card.GetFullName());

            Console.ReadLine();
        }
Пример #7
0
        static void Main(string[] args)
        {
            Deck deck = new Deck(52);

            int counter = 0;

            for (int i = 2; i <= 14; i++)
            {
                for (int j = 1; j <= 4; j++)
                {
                    string faceValue;
                    if (i < 11)
                    {
                        faceValue = i.ToString();
                    }
                    else if (i == 11)
                    {
                        faceValue = "Jack";
                    }
                    else if (i == 12)
                    {
                        faceValue = "Queen";
                    }
                    else if (i == 13)
                    {
                        faceValue = "King";
                    }
                    else
                    {
                        faceValue = "Ace";
                    }

                    string suit;
                    if (j == 1)
                    {
                        suit = "Hearts";
                    }
                    else if (j == 2)
                    {
                        suit = "Diamonds";
                    }
                    else if (j == 3)
                    {
                        suit = "Clubs";
                    }
                    else
                    {
                        suit = "Spades";
                    }

                    deck.Cards[counter] = new Card
                    {
                        FaceValue = faceValue,
                        Suit      = suit
                    };

                    counter++;
                }
            }

            Console.WriteLine(deck.Draw().FullCardName());
            Console.ReadLine();
        }
Пример #8
0
        static void Main(string[] args)
        {
            // Creating the Deck

            Deck playingDeck = new Deck();

            // Checking to make sure the Deck was created properly

            // foreach(Card card in playingDeck.PlayerDeck)
            // {
            //     Console.WriteLine(card.stringVal);
            // }

            //Test the Draw method
            Card Hand = playingDeck.Draw();

            Console.WriteLine("You drew..." + Hand.stringVal);

            //Making sure Card was removed.
            // foreach(Card card in playingDeck.PlayerDeck)
            // {
            //     Console.WriteLine(card.stringVal);
            // }
            // foreach(Card card in playingDeck.Backup)
            // {
            //     Console.WriteLine(card.stringVal);
            // }

            //Testing the Reset method
            playingDeck.PlayerDeck = playingDeck.Reset();

            // Console.WriteLine("player deck has been reset");
            // foreach(Card card in playingDeck.PlayerDeck)
            // {
            //     Console.WriteLine(card.stringVal);
            // }

            //Testing the shuffle method a few times

            Console.WriteLine("player deck will now be shuffled!!");
            playingDeck.PlayerDeck = playingDeck.Shuffle(playingDeck.PlayerDeck);
            // foreach(Card card in playingDeck.PlayerDeck)
            // {
            //     Console.WriteLine(card.stringVal);
            // }
            Console.WriteLine("player deck will now be shuffled again!!");
            playingDeck.PlayerDeck = playingDeck.Shuffle(playingDeck.PlayerDeck);
            // foreach(Card card in playingDeck.PlayerDeck)
            // {
            //     Console.WriteLine(card.stringVal);
            // }

            Console.WriteLine("player deck will now be shuffled again!!");
            playingDeck.PlayerDeck = playingDeck.Shuffle(playingDeck.PlayerDeck);
            // foreach(Card card in playingDeck.PlayerDeck)
            // {
            //     Console.WriteLine(card.stringVal);
            // }

            //Creating the Player
            Player Jesus = new Player("Jesus");

            //Grabbing 5 cards from the deck
            Jesus.DrawHand(playingDeck);
            Jesus.ShowHand();

            Jesus.Discard(playingDeck, 2);
            Jesus.Discard(playingDeck, 5);
            Jesus.DrawCard(playingDeck);
            Jesus.ShowHand();
        }
        static void Main(string[] args)
        {
            Deck myDeck = new Deck();

            Card topCard = myDeck.Draw();
        }