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();
        }
        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();
        }
 public void OneDeck_InitializeThenShuffleThenSort_NoDuplicates()
 {
     Deck testdeck = new Deck();
     testdeck.InitializeFullDeck();
     testdeck.Shuffle();
     testdeck.Sort();
     Assert.AreEqual(testdeck.AreCardsUnique(), true);
 }
        public void TwoDecks_SortADeckAndCompareToSortedDeck()
        {
            Deck testdeck = new Deck();

            testdeck.Shuffle();
            testdeck.Sort();
            var my = testdeck.TupCards.ToArray();
            var my2 = SortedTestDeck.Instance.Cards.ToArray();

            CollectionAssert.AreEqual(my, my2);
        }
Esempio n. 5
0
 private void ResetDeck(int deckNumber)
 {
     if (deckNumber == 1)
     {
         int numberOfCards = random.Next(1, 11);
         deckNo1 = new Deck(new Card[] { });
         for (int i = 0; i < numberOfCards; i++)
         {
             deckNo1.Add(new Card((Suits)random.Next(4), (Values)random.Next(1, 14)));
         }
         deckNo1.Sort();
     }
     else if (deckNumber == 2)
     {
         deckNo2 = new Deck();
     }
 }
Esempio n. 6
0
        private void ResetDeck(int deckNumber)
        {
            // Esvazia e reinicializa o deck (1 com 10 ou 2 com 52 cartas)

            if (deckNumber == 1)
            {
                int numberOfCards = _random.Next(1, 11);
                _deck1 = new Deck(Array.Empty <Card>());
                for (int i = 0; i < numberOfCards; i++)
                {
                    _deck1.Add(new Card((Card.Suits)_random.Next(4),
                                        (Card.Values)_random.Next(1, 14)));
                }
                _deck1.Sort();
            }
            else
            {
                _deck2 = new Deck();
            }
        }
Esempio n. 7
0
        static void CardDeck()
        {
            // TODO: Declare a Deck to work with
            Deck deck = new Deck();

            // Create the menu loop
            bool keepGoing = true;

            while (keepGoing)
            {
                Console.Clear();
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("What do you want to do? ");
                Console.WriteLine("1. Create a new deck of cards");
                Console.WriteLine("2. Shuffle cards");
                Console.WriteLine("3. Deal Cards");
                Console.WriteLine("Q. Quit");

                string input = Console.ReadLine().ToLower();
                if (input.Length > 0)
                {
                    input = input.Substring(0, 1);
                }

                switch (input)
                {
                case "q":
                    keepGoing = false;
                    continue;

                case "1":
                    // Create a new deck of cards
                    deck = new Deck();
                    break;

                case "2":
                    // Shuffle the deck
                    deck.Shuffle();
                    break;

                case "3":
                    // Deal cards from the deck
                    DealCards(deck);
                    break;

                // Hidden menu items for Sorting
                case "4":
                    deck.Sort(Deck.SortBy.ValueThenSuit);
                    break;

                case "5":
                    deck.Sort(Deck.SortBy.ValueAceHigh);
                    break;

                case "6":
                    deck.Sort(Deck.SortBy.SuitThenValue);
                    break;

                case "7":
                    deck.Sort(Deck.SortBy.CardName);
                    break;

                default:
                    continue;
                }

                // Wait for user to press enter and clear screen.
                Console.ReadLine();
            }
        }
        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);
        }
 public void OneDeck_ShuffledThenSorted_WillBeSorted()
 {
     Deck testdeck = new Deck();
     testdeck.InitializeFullDeck();
     testdeck.Shuffle();
     testdeck.Sort();
     Assert.AreEqual(testdeck.IsSorted(), true);
 }
Esempio n. 10
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();
        }
Esempio n. 11
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();
        }