Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Deck deck = new Deck();


            for (int i = 0; i <= 3; i++)
            {
                string suit = "";
                if (i == 0) suit = "hearts";
                else if (i == 1) suit = "diamonds";
                else if (i == 2) suit = "clubs";
                else if (i == 3) suit = "spades";

                for (int j = 2; j <= 14; j++)
                {
                    Card card = new Card { Suit = suit, Number = j };
                    deck.AddCard(card);
                }
            }

            deck.PrintDeck();
            deck.Shuffle();
            deck.Shuffle();
            deck.Shuffle();
            deck.PrintDeck();
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
0
		public static void Main()
		{
			IDeck deck = new Deck();
			IEnumerable<Card> hand = deck.TakeCards(13);

			Console.WriteLine("Displaying hand:");
			foreach (Card card in hand)
				Console.WriteLine(card.ToString());
			Console.ReadLine();

			Console.WriteLine("Displaying remaining deck:");
			Console.Write(deck.ToString());
			Console.ReadLine();

			deck.Shuffle();

			Console.WriteLine("Displaying remaining, shuffled deck:");
			Console.Write(deck.ToString());
			Console.ReadLine();

			Card takenCard = deck.TakeCard();

			Console.WriteLine("Displaying next card delt from deck:");
			Console.WriteLine(takenCard.ToString());
			Console.ReadLine();

			Console.WriteLine("Displaying remaining deck:");
			Console.Write(deck.ToString());
			Console.ReadLine();
		}
 public void OneDeck_InitializeThenShuffle_NoDuplicates()
 {
     Deck testdeck = new Deck();
     testdeck.InitializeFullDeck();
     testdeck.Shuffle();
     Assert.AreEqual(testdeck.AreCardsUnique(), true);
 }
 public void OneDeck_DeckShuffled_WillNotBeSorted()
 {
     Deck testdeck = new Deck();
     testdeck.InitializeFullDeck();
     testdeck.Shuffle();
     Assert.AreEqual(testdeck.IsSorted(), false);
 }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            Deck deck1 = new Deck();

            /* Read The Initalized Cards */
            foreach (var card in deck1.TupCards)
            {
                Console.Write("drew {0} of {1}\n", Card.GetCardValue(card.Item1), Card.GetCardSuit(card.Item2));
            }

            /* Shuffle Cards */
            Console.Write("\n\nShuffle The Deck\n\n");
            deck1.Shuffle();

            /* Read Shuffled Cards */
            foreach (var card in deck1.TupCards)
            {
                Console.Write("drew {0} of {1}\n", Card.GetCardValue(card.Item1), Card.GetCardSuit(card.Item2));
            }

            /* Sort Them Again */
            Console.Write("\n\nSort The Deck\n\n");
            deck1.Sort();
            foreach (var card in deck1.TupCards)
            {
                Console.Write("drew {0} of {1}\n", Card.GetCardValue(card.Item1), Card.GetCardSuit(card.Item2));
            }

            Console.ReadLine();
        }
Exemplo n.º 7
0
 static void Main(string[] args)
 {
     var deck = new Deck();
     deck.PrintDeck();
     deck.Shuffle();
     Console.WriteLine("\nSHUFFLED\n");
     deck.PrintDeck();
     Console.ReadKey();
 }
        public void TwoDecks_ShuffleADeckAndCompareToSortedDeck()
        {
            Deck testdeck = new Deck();

            testdeck.Shuffle();
            var my = testdeck.TupCards.ToArray();
            var my2 = SortedTestDeck.Instance.Cards.ToArray();
            CollectionAssert.AreNotEqual(my, my2);
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
0
        public void TwoDeck_ShuffleOneSortOther_BothHaveKeptState()
        {
            Deck testdeck = new Deck();
            Deck testdeck2 = new Deck();

            testdeck.InitializeFullDeck();
            testdeck2.InitializeFullDeck();

            testdeck.Shuffle();
            testdeck.Sort();
            testdeck2.Shuffle();

            Assert.AreEqual(testdeck.IsSorted(), true);
            Assert.AreEqual(testdeck2.IsSorted(), false);
        }
Exemplo n.º 11
0
 public void OneDeck_ShuffledThenSorted_WillBeSorted()
 {
     Deck testdeck = new Deck();
     testdeck.InitializeFullDeck();
     testdeck.Shuffle();
     testdeck.Sort();
     Assert.AreEqual(testdeck.IsSorted(), true);
 }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            Deck deck1 = new Deck();
            int  k;

            for (int i = 0; i < 2; i++)
            {
                for (int j = 1; j < (6 + 1); j++)
                {
                    deck1.Cards.Add(new Card {
                        cardsuit = i, cardvalue = j
                    });
                }
            }
            if (deck1.IsSorted())
            {
                Console.WriteLine("\nYes the incomplete Deck is Sorted\n");
            }

            for (Card tmpcard = deck1.DealCard(); tmpcard != null; tmpcard = deck1.DealCard())
            {
                Console.Write("drew: a(n)  {0}\n", Card.GetCardName(tmpcard));
            }
            Console.WriteLine("\n\nLet's Shuffle The Deck!\n\n");


            deck1.Shuffle();
            for (Card tmpcard = deck1.DealCard(); tmpcard != null; tmpcard = deck1.DealCard())
            {
                Console.Write("drew: a(n)  {0}\n", Card.GetCardName(tmpcard));
            }

            Console.WriteLine("\nLet's Initialize a full deck\n");
            deck1.InitializeFullDeck();

            bool tmp = deck1.AreCardsUnique();

            if (tmp && deck1.Cards.Count() == 52)
            {
                Console.WriteLine("We have 52 card and no duplicates - we have an official set!\n\n");
            }

            for (Card tmpcard = deck1.DealCard(); tmpcard != null; tmpcard = deck1.DealCard())
            {
                Console.Write("drew: a(n)  {0}\n", Card.GetCardName(tmpcard));
            }

            Console.WriteLine("\n\nLet's Shuffle The Deck!\n\n");

            deck1.Shuffle();

            if (!deck1.IsSorted())
            {
                Console.WriteLine("\nThe Deck is not Sorted\n");
            }

            k = 1;

            foreach (var card in deck1.Cards)
            {
                Console.WriteLine("({0}) drew a {1}", k++, Card.GetCardName(card));
            }

            Console.WriteLine("\n\nLet's Sort The Deck!\n\n");

            deck1.Sort();

            if (deck1.IsSorted())
            {
                Console.WriteLine("\nYes the Deck is Sorted\n");
            }

            k = 1;

            foreach (var card in deck1.Cards)
            {
                Console.WriteLine("({0}) drew a(n) {1}", k++, Card.GetCardName(card));
            }

            Console.ReadLine();
        }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            Deck deck1 = new Deck();
            int k;
            for (int i = 0; i < 2; i++)
            {
                for (int j = 1; j< (6 + 1); j++)
                {
                    deck1.Cards.Add(new Card { cardsuit = i, cardvalue = j });
                }
            }
            if (deck1.IsSorted())
            {
                Console.WriteLine("\nYes the incomplete Deck is Sorted\n");
            }

            for (Card tmpcard = deck1.DealCard(); tmpcard != null; tmpcard = deck1.DealCard())
            {
                Console.Write("drew: a(n)  {0}\n", Card.GetCardName(tmpcard));
            }
            Console.WriteLine("\n\nLet's Shuffle The Deck!\n\n");

            deck1.Shuffle();
            for (Card tmpcard = deck1.DealCard(); tmpcard != null; tmpcard = deck1.DealCard())
            {
                Console.Write("drew: a(n)  {0}\n", Card.GetCardName(tmpcard));
            }

            Console.WriteLine("\nLet's Initialize a full deck\n");
            deck1.InitializeFullDeck();

            bool tmp = deck1.AreCardsUnique();
            if (tmp && deck1.Cards.Count() == 52)
                Console.WriteLine("We have 52 card and no duplicates - we have an official set!\n\n");

            for (Card tmpcard = deck1.DealCard(); tmpcard != null; tmpcard = deck1.DealCard())
            {
                Console.Write("drew: a(n)  {0}\n", Card.GetCardName(tmpcard));
            }

            Console.WriteLine("\n\nLet's Shuffle The Deck!\n\n");

            deck1.Shuffle();

            if (!deck1.IsSorted())
            {
                Console.WriteLine("\nThe Deck is not Sorted\n");
            }

            k = 1;

            foreach (var card in deck1.Cards)
                Console.WriteLine("({0}) drew a {1}", k++, Card.GetCardName(card));

            Console.WriteLine("\n\nLet's Sort The Deck!\n\n");

            deck1.Sort();

            if (deck1.IsSorted())
            {
                Console.WriteLine("\nYes the Deck is Sorted\n");
            }

            k = 1;

            foreach (var card in deck1.Cards)
                Console.WriteLine("({0}) drew a(n) {1}", k++, Card.GetCardName(card));

            Console.ReadLine();
        }