Exemplo n.º 1
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();
		}
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Deck deck    = null;
            bool playing = true;

            Console.WriteLine("Cards!");
            Console.WriteLine("Q – quit the application");
            Console.WriteLine("N – Create New Deck");
            Console.WriteLine("S – Shuffle Current Deck");
            Console.WriteLine("D - Draw Card");
            Console.WriteLine("R - Display Deck");

            while (playing)
            {
                char input = Console.ReadKey().KeyChar;
                Console.WriteLine();

                switch (input)
                {
                case 'Q':
                case 'q':
                    playing = false;
                    break;

                case 'N':
                case 'n':
                    deck = new Deck();
                    Console.WriteLine("Created new Deck.");
                    break;

                case 'S':
                case 's':
                    if (deck == null)
                    {
                        Console.WriteLine("No Deck");
                    }
                    else
                    {
                        deck.Shuffle();
                        Console.WriteLine("Deck Shuffled");
                    }
                    break;

                case 'D':
                case 'd':
                    if (deck == null)
                    {
                        Console.WriteLine("No Deck");
                    }
                    else
                    {
                        Card card = deck.DrawTopCard();
                        Console.WriteLine(card.ToString());
                    }
                    break;

                case 'R':
                case 'r':
                    if (deck == null)
                    {
                        Console.WriteLine("No Deck");
                    }
                    else
                    {
                        Console.WriteLine(deck.ToString());
                    }
                    break;

                default:
                    Console.WriteLine("Invalid Input");
                    break;
                }
            }
        }