Beispiel #1
0
        static void Main(string[] args)
        {
            //delcare new deck
            var Deck = new Deck();

            //shuffle the cards
            Deck.Shuffle();

            //deal cards
            List<Cards> ListofCards = new List<Cards>();
            ListofCards = Deck.Deal();
            Console.WriteLine("\n\nDealt Cards: ");
            Console.WriteLine();
            foreach (var item in ListofCards)
            {
                item.DealFromDeck();
            }

            //deal cards
            List<Cards> ListofCards2 = new List<Cards>();
            ListofCards2 = Deck.Deal();
            Console.WriteLine("\n\nDealt Cards: ");
            Console.WriteLine();
            foreach (var item in ListofCards2)
            {
                item.DealFromDeck();
            }

            //keep window open
            Console.ReadKey();
        }
Beispiel #2
0
        private void SetUp()
        {
            Deck aDeck = new Deck(new Suit[] {Suit.Clubs, Suit.Diamonds}, 
                new FaceValue[] {FaceValue.King, FaceValue.Queen, FaceValue.Jack, FaceValue.Ten});

            aDeck.Shuffle();
            m_Hand1 = new Hand();
            m_Hand2 = new Hand();
            aDeck.Deal(new Hand[]{m_Hand1, m_Hand2});
            ShowHand(panel1, m_Hand1);
            ShowHand(panel2, m_Hand2);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Deck deck = new Deck();

            deck.Shuffle();
            deck.Shuffle();
            Player player  = new Player("Owen", deck.Deal(5));
            Player player2 = new Player("Kris", deck.Deal(5));

            int i = 0;

            while (player.CheckHand() < PokerHand.FourOfAKind || player2.CheckHand() < PokerHand.FourOfAKind)
            {
                if (deck.Cards.Count() < 5)
                {
                    deck.Shuffle();
                }
                player = new Player("Owen", deck.Deal(5));
                if (deck.Cards.Count() < 5)
                {
                    deck.Shuffle();
                }
                player2 = new Player("Kris", deck.Deal(5));
                var x = player2.CheckHand();
                var y = player.CheckHand();
                if (player.CheckHand() == PokerHand.FourOfAKind || player2.CheckHand() == PokerHand.FourOfAKind)
                {
                    i++;
                    Console.WriteLine(i);
                }
            }

            Console.WriteLine(player.GetHand() + "\n" + player2.GetHand());
            Console.WriteLine(player.Name + " has a " + player.CheckHand() + "\n");
            Console.WriteLine(player2.Name + " has a " + player2.CheckHand());
            Console.ReadKey();
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            Deck newDeck = new Deck();

            Console.WriteLine("Card Dealt: " + newDeck.Deal().stringVal);
            Console.WriteLine("Deck Count: " + newDeck.deck.Count);
            newDeck.Reset();
            Console.WriteLine("Deck Reset: " + newDeck.deck.Count);
            newDeck.Shuffle();
            Console.WriteLine("Shuffled Deck Top Card: " + newDeck.deck[0].stringVal);
            Player player1 = new Player("John");

            player1.Draw(newDeck);
            Console.WriteLine("Player First Card: " + player1.hand[0].suit + " " + player1.hand[0].stringVal);
            Console.WriteLine("Player discards: " + player1.Discard().stringVal);
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Deck testDeck = new Deck();

            System.Console.WriteLine(testDeck);
            System.Console.WriteLine(testDeck.mycards);
            System.Console.WriteLine(testDeck.Deal());
            System.Console.WriteLine(testDeck.Reset());
            System.Console.WriteLine(testDeck.Reset());
            Players player1 = new Players("nate");

            Console.WriteLine(player1);
            player1.Draw(testDeck);
            System.Console.WriteLine(player1.Draw(testDeck));
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            Deck   newDeck = new Deck();
            Player p1      = new Player();

            newDeck.Deal();
            newDeck.Deal();
            newDeck.Deal();
            p1.Draw(newDeck.Deal());
            p1.Draw(newDeck.Deal());
            p1.Draw(newDeck.Deal());
            p1.Discard(0);
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            Deck myDeck = new Deck(); // makes a deck instance

            Console.WriteLine(myDeck.Deal());
            Console.WriteLine(myDeck.Cards.Count);
            myDeck.Reset();
            Console.WriteLine(myDeck.Cards.Count);
            myDeck.Shuffle();
            Player myPlayer = new Player("John");

            myPlayer.Draw(myDeck);
            Console.WriteLine(myDeck.Cards.Count);
            myPlayer.Draw(myDeck);
            myPlayer.Draw(myDeck);
            myPlayer.Draw(myDeck);
            myPlayer.Draw(myDeck);
            Console.WriteLine(myDeck.Cards.Count);
            myPlayer.Discard(myPlayer.Hand, 3);
            Console.WriteLine(myPlayer.Hand.Count);
        }
        static void Main(string[] args)
        {
            Deck newdeck = new Deck();

            newdeck.ReadDeck();
            newdeck.Deal();
            newdeck.ReadDeck();
            newdeck.Shuffle();
            System.Console.WriteLine("*********");
            // newdeck.Shuffle();
            Player Jason = new Player("Jason");

            Jason.Draw(newdeck);
            Jason.Draw(newdeck);
            Jason.Draw(newdeck);
            Jason.Draw(newdeck);
            Jason.Draw(newdeck);
            foreach (Card card in Jason.Hand)
            {
                System.Console.WriteLine(card.stringVals);
            }
        }
 public void DrawCard(Deck deck)
 {
     Hand.Add(deck.Deal());
 }
Beispiel #10
0
 public Player(string Iname, Deck IDeck)
 {
     name = Iname;
     hand = IDeck.Deal();
 }
Beispiel #11
0
 public Card Draw(Deck d1)
 {
     hand.Add(d1.Deal());
     return(hand[hand.Count - 1]);
 }
Beispiel #12
0
        // Methods
        public void Draw(Deck ThisDeck)
        {
            Card PlayerCard = ThisDeck.Deal();

            this.Hand.Add(PlayerCard);
        }
Beispiel #13
0
        //==================== Methods =====================//
        public void Draw(Deck deck)
        {
            Card DeltCard = deck.Deal();

            Hand.Add(DeltCard);
        }
Beispiel #14
0
        static void Main(string[] args)
        {
            //creating variables
            Deck deck  = new Deck();
            Card cards = new Card();

            //setting the interger counter to zero
            int counter = 0;

            for (int i = 2; i <= 14; i++) //loop through the face value
            {
                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";
                }

                for (int j = 1; j <= 4; j++) //looping through the suit...inside a loop
                {
                    string suit;
                    if (j == 1)
                    {
                        suit = "Hearts";
                    }
                    else if (j == 2)
                    {
                        suit = "Diamonds";
                    }
                    else if (j == 3)
                    {
                        suit = "Spades";
                    }
                    else
                    {
                        suit = "Clubs";
                    }

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

            var card = deck.Deal();

            Console.WriteLine(card.CardName);

            Console.ReadLine();
        }
Beispiel #15
0
 public void Draw(Deck deck)
 {
     hand.Add(deck.Deal());
 }
Beispiel #16
0
        static void Main(string[] args)
        {
            // Let's store all of our cards in a list
            // CODE GOES HERE

            Deck        deck        = new Deck();
            List <Card> player1Hand = new List <Card>();
            List <Card> player2Hand = new List <Card>();

            Console.OutputEncoding = System.Text.Encoding.UTF8;
            Console.WriteLine("♠♥♦♣ Welcome to Cards ♠♥♦♣");

            while (true)
            {
                Console.WriteLine("What do you want to do? ");
                Console.WriteLine("1. Create a new deck of cards");
                Console.WriteLine("2. Deal two hands of cards");
                Console.WriteLine("3. Show the players' hands");
                Console.WriteLine("Q. Quit");

                string input = Console.ReadLine();

                if (input == "1")
                {
                    // Create a new deck of cards
                    deck.Reset();
                }
                else if (input == "2")
                {
                    // Deal cards to two players
                    player1Hand = new List <Card>();
                    for (int i = 1; i <= 5; i++)
                    {
                        player1Hand.Add(deck.Deal());
                    }

                    player2Hand = new List <Card>();
                    for (int i = 1; i <= 5; i++)
                    {
                        player2Hand.Add(deck.Deal());
                    }
                }
                else if (input == "3")
                {
                    // Show both hands on the Console
                    Console.WriteLine("Player 1");
                    foreach (Card card in player1Hand)
                    {
                        Console.WriteLine($"\t{card.Name}");
                    }

                    Console.WriteLine("====================");
                    Console.WriteLine("Player 2");
                    foreach (Card card in player2Hand)
                    {
                        Console.WriteLine($"\t{card.Name}");
                    }
                }
                else if (input == "Q")
                {
                    break;
                }

                // Wait for user to press enter and clear screen.
                Console.ReadLine();
                Console.Clear();
            }
        }
Beispiel #17
0
 public void DrawFrom(Deck currentDeck)
 {
     hand.Add(currentDeck.Deal());
 }
Beispiel #18
0
        public void Draw(Deck adeck)
        {
            var playercard = (DeckOfCards.Card)adeck.Deal();

            Hand.Add(playercard);
        }
Beispiel #19
0
 public Card Draw(Deck cards)
 {
     hand.Add(cards.Deal());
     return(hand[0]);
 }
Beispiel #20
0
        /// <summary>
        /// Instantiate Cards based on enum values
        /// Instantiate a Deck of type Card and fill it with the created cards
        /// Add a card
        /// Remove a card
        /// Shuffle the deck
        /// </summary>
        public static void UseTheDeck()
        {
            //create objects of Card type
            //pass in the 2 enums for each
            Cards card1  = new Cards((Values)1, (SuitsinDeck)1);
            Cards card2  = new Cards((Values)1, (SuitsinDeck)2);
            Cards card3  = new Cards((Values)1, (SuitsinDeck)3);
            Cards card4  = new Cards((Values)1, (SuitsinDeck)4);
            Cards card5  = new Cards((Values)2, (SuitsinDeck)1);
            Cards card6  = new Cards((Values)2, (SuitsinDeck)2);
            Cards card7  = new Cards((Values)2, (SuitsinDeck)3);
            Cards card8  = new Cards((Values)2, (SuitsinDeck)4);
            Cards card9  = new Cards((Values)3, (SuitsinDeck)1);
            Cards card10 = new Cards((Values)3, (SuitsinDeck)2);
            Cards card11 = new Cards((Values)3, (SuitsinDeck)3);
            Cards card12 = new Cards((Values)3, (SuitsinDeck)4);
            Cards card13 = new Cards((Values)4, (SuitsinDeck)1);
            Cards card14 = new Cards((Values)4, (SuitsinDeck)2);
            Cards card15 = new Cards((Values)4, (SuitsinDeck)3);
            Cards card16 = new Cards((Values)4, (SuitsinDeck)4);

            //Collections initializer
            //add all the cards that were instantiated
            //to the newly instantiated Deck of type Cards
            Deck <Cards> DeckOfCards = new Deck <Cards> {
                card1, card2, card3, card4, card5, card6, card7, card8,
                card9, card10, card11, card12, card13, card14, card15, card16
            };

            //GetEnumerator was implemented in the Deck class
            //display the entire deck
            foreach (Cards card in DeckOfCards)
            {
                Console.WriteLine($"{card.Values} of {card.SuitsinDeck}");
            }
            Console.Read();
            Console.Clear();
            Console.Read();

            //adding a card to the deck requires an instantiation of a new Card object
            Console.WriteLine("Let's add a Ten of Spades to the deck:");
            Cards card17 = new Cards((Values)5, (SuitsinDeck)1);

            DeckOfCards.Add(card17);
            foreach (Cards card in DeckOfCards)
            {
                Console.WriteLine($"{card.Values} of {card.SuitsinDeck}");
            }
            Console.ReadLine();
            Console.Clear();

            //removing the most recently added card:
            Console.WriteLine($"Let's remove that {card17.Values} of {card17.SuitsinDeck} from the deck:");
            DeckOfCards.Remove(card16);
            foreach (Cards card in DeckOfCards)
            {
                Console.WriteLine($"{card.Values} of {card.SuitsinDeck}");
            }
            Console.Read();
            Console.Clear();

            //shuffling the deck:
            Console.WriteLine("Let's shuffle the deck: ");
            DeckOfCards.Deal(DeckOfCards);
            foreach (Cards card in DeckOfCards)
            {
                Console.WriteLine($"{card.Values} of {card.SuitsinDeck}");
            }
            Console.Read();
            DeckOfCards.Deal(DeckOfCards);
            Console.WriteLine("<------Shuffling Again------>");
            foreach (Cards card in DeckOfCards)
            {
                Console.WriteLine($"{card.Values} of {card.SuitsinDeck}");
            }
            Console.Read();
        }
Beispiel #21
0
 public void Draw(Deck shuffledDeck)
 {
     hand.Add(shuffledDeck.Deal());
 }