static void Main(string[] args)
        {
            List <Speelkaart> cards = new List <Speelkaart>();

            for (int i = 0; i < 4; i++)
            {
                for (int j = 1; j <= 13; j++)
                {
                    cards.Add(new Speelkaart(j, (Suite)i));
                }
            }
            Stack <Speelkaart> shuffledCards = ShuffleCards(cards);
            //foreach (var item in shuffledCards)
            //{
            //    Console.WriteLine(item.ToString());
            //}

            //Console.WriteLine("Think of a card.");
            //foreach (Speelkaart card in shuffledCards)
            //{
            //    Console.WriteLine("Is this your card?");
            //    Console.WriteLine(card.ToString());
            //    Console.ReadLine();
            //}

            //Console.WriteLine("No more cards.");

            // Part 2
            string     input = "";
            Speelkaart inputCard;

            do
            {
                Console.WriteLine("Guess the next card: (\"number\" of \"Card Type\")");
                Console.WriteLine($"CHEAT| {shuffledCards.Peek()} |CHEAT");

                input     = Console.ReadLine();
                inputCard = Speelkaart.StringToCard(input);

                if (Speelkaart.StringToCard(input).Equals(shuffledCards.Peek()))
                {
                    Console.Clear();
                    Console.WriteLine($"Correct! It was indeed: {shuffledCards.Peek()}.\nTry again...");
                    shuffledCards.Pop();
                }
                else
                {
                    Console.WriteLine("Wrong! Try again.");
                }
            } while (shuffledCards.Count > 0);
        }
예제 #2
0
        public override bool Equals(object obj)
        {
            Speelkaart speelkaart = obj as Speelkaart;

            if (speelkaart != null)
            {
                if (Getal == speelkaart.Getal && Suite == speelkaart.Suite)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #3
0
        static void Main(string[] args)
        {
            var pakkaarten = Speelkaart.GenerateDeck();
            Stack <Speelkaart> shuffledDeck = Speelkaart.ShuffleDeck(pakkaarten);

            for (int i = 0; i < 5; i++)
            {
                var playerPick = PlayerInput();
                var aiPick     = shuffledDeck.Pop();

                if (playerPick.Equals(aiPick))
                {
                    Console.WriteLine("Goed geraden!");
                }
                else
                {
                    Console.WriteLine($"Spijtig. De kaart was {aiPick}");
                }
            }
        }
예제 #4
0
        static void Main(string[] args)
        {
            if (OperatingSystem.IsWindows())             // prevent warning windows only
            {
                Console.SetWindowSize(44, 15);
            }
            Console.CursorVisible   = false;
            Console.BackgroundColor = ConsoleColor.White;

            Deck deck      = new Deck();
            int  score     = 0;
            int  cardvalue = 0;

            do
            {
                Console.Clear();

                Speelkaart speelkaart = deck.ShuffeldDeck.Pop();
                cardvalue += speelkaart.CardValue;
                Console.ForegroundColor = speelkaart.Color;
                Console.WriteLine(speelkaart.DrawCard());

                Console.ForegroundColor = ConsoleColor.Black;
                Console.SetCursorPosition(10, 0);
                Console.WriteLine($"score is {score}");
                Console.SetCursorPosition(10, 1);
                Console.WriteLine($"Total card value is {cardvalue}");

                if (!PlayerInput())
                {
                    cardvalue = 0;
                }

                if (cardvalue > 21)
                {
                    score--;
                    cardvalue = 0;
                }
                if (cardvalue == 21)
                {
                    score++;
                    cardvalue = 0;
                }
            } while (deck.ShuffeldDeck.Count != 0);

            if (score < 0)
            {
                Console.BackgroundColor = ConsoleColor.Red;
                Console.ForegroundColor = ConsoleColor.White;
                Console.Clear();
                Console.WriteLine(@"
██╗   ██╗ ██████╗ ██╗   ██╗      
╚██╗ ██╔╝██╔═══██╗██║   ██║      
 ╚████╔╝ ██║   ██║██║   ██║      
  ╚██╔╝  ██║   ██║██║   ██║      
   ██║   ╚██████╔╝╚██████╔╝      
   ╚═╝    ╚═════╝  ╚═════╝       
                                 
██╗      ██████╗ ███████╗███████╗
██║     ██╔═══██╗██╔════╝██╔════╝
██║     ██║   ██║███████╗█████╗  
██║     ██║   ██║╚════██║██╔══╝  
███████╗╚██████╔╝███████║███████╗
╚══════╝ ╚═════╝ ╚══════╝╚══════╝                                                                                                                  
");
            }
            else
            {
                Console.BackgroundColor = ConsoleColor.Green;
                Console.ForegroundColor = ConsoleColor.White;
                Console.Clear();
                Console.WriteLine(@"
██╗   ██╗ ██████╗ ██╗   ██╗    
╚██╗ ██╔╝██╔═══██╗██║   ██║    
 ╚████╔╝ ██║   ██║██║   ██║    
  ╚██╔╝  ██║   ██║██║   ██║    
   ██║   ╚██████╔╝╚██████╔╝    
   ╚═╝    ╚═════╝  ╚═════╝     
                               
██╗    ██╗██╗███╗   ██╗        
██║    ██║██║████╗  ██║        
██║ █╗ ██║██║██╔██╗ ██║        
██║███╗██║██║██║╚██╗██║        
╚███╔███╔╝██║██║ ╚████║        
 ╚══╝╚══╝ ╚═╝╚═╝  ╚═══╝                                       
");
            }
            Console.ReadLine();
        }