コード例 #1
0
ファイル: Program.cs プロジェクト: PeachyPear1/TriviaGame
 static void Main()
 {
     Game.Start();
     Game.ShowWelcome();
     TriviaItem.ShowText();
     Game.ShowQuestion();
 }
コード例 #2
0
        public void Play()
        {
            // Trick to set the background color for the whole console using Clear.
            BackgroundColor = ConsoleColor.White;
            Clear();

            ForegroundColor = ConsoleColor.Blue;

            // Display the welcome screen for the game.
            WriteLine("Welcome to " + Title);
            WriteLine(Description);

            // Create the player and welcome them.
            Write("What is your name: ");
            string playerName    = ReadLine();
            Player currentPlayer = new Player(playerName);

            WriteLine("Welcome to " + Title + ", " + currentPlayer.Name + "!");

            // Create a question.
            string     catPrompt   = "Cats have more bones than humans - true or false?";
            string     catAnswer   = "true";
            TriviaItem catQuestion = new TriviaItem(catPrompt, catAnswer);

            WriteLine("Question 1");
            WriteLine(catQuestion.Question);
            string catPlayerResponse = ReadLine();

            // Conditionals allow us to use branching logic.
            if (catPlayerResponse == catQuestion.Answer)
            {
                WriteLine("You got it right!");
            }
            else
            {
                WriteLine("Try again.");
            }

            WriteLine("Press any key to exit...");
            ReadKey();
        }
コード例 #3
0
        public static void CheckResponse()
        {
            Clear();
            WriteLine("Question #2:");
            TriviaItem octopus = new TriviaItem();

            octopus.Question = "Octopuses have 8 tentacles. True or false?";
            WriteLine($"{octopus.Question}");
            TriviaItem.Answer = ReadLine();
            if (TriviaItem.Answer == "False")
            {
                WriteLine("That answer is correct!");
                Display.ShowNumberofQuestions();
            }
            else
            {
                WriteLine("Sorry, that wasn't the answer. The right response was FALSE.");
                WriteLine("Try again next time!");
                WriteLine("Press enter to continue.");
                ReadKey();
                Game.End();
            }
        }
コード例 #4
0
        public static void ShowQuestion()
        {
            Clear();
            WriteLine("Question #1:");
            TriviaItem butterfly = new TriviaItem();

            butterfly.Question = "Monarch butterflies only eat milkweed. True or false?";
            WriteLine($"{butterfly.Question}");
            TriviaItem.Answer = ReadLine();
            if (TriviaItem.Answer == "True")
            {
                WriteLine("Correct!");
                Display.ShowPoints();
            }
            else
            {
                WriteLine("That was incorrect! The answer was TRUE.");
                WriteLine("Maybe you'll have better luck on the next question.");
                WriteLine("Press enter to continue.");
                ReadKey();
                Game.CheckResponse();
            }
        }
コード例 #5
0
        private void Play()
        {
            TriviaItem tinkerbellPan = new TriviaItem();

            tinkerbellPan.Question = "What is the name of the fairy in Peter Pan?";
            tinkerbellPan.Answer   = "Tinkerbell";

            TriviaItem starwarsDad = new TriviaItem();

            starwarsDad.Question = "In Star Wars, Palpatine reveals to Luke that he is his father. True or false?";
            starwarsDad.Answer   = "false";

            TriviaItem animalCrossing = new TriviaItem();

            animalCrossing.Question = "Animal Crossing New Horizons is one of Nintendo's all time, best selling titles for the Switch. True or false?";
            animalCrossing.Answer   = "true";

            TriviaItem boondocksThe = new TriviaItem();

            boondocksThe.Question = "What is the name of the suburb where the main characters of The Boondocks live?";
            boondocksThe.Answer   = "Woodcrest";

            TriviaItem spongebobFriend = new TriviaItem();

            spongebobFriend.Question = "Who is Spongebob's best friend in Spongebob Squarepants?";
            spongebobFriend.Answer   = "Patrick Star";

            TriviaItem johnWick = new TriviaItem();

            johnWick.Question = "Which actor portrays John Wick in the John Wick films? (Hint: Played Neo in The Matrix films)";
            johnWick.Answer   = "Keanu Reeves";



            string input;

            WriteLine(tinkerbellPan.Question);
            input = ReadLine();
            WriteLine("Your answer: " + input + ".");
            WriteLine("The correct answer is Tinkerbell.");
            WriteLine("Press ENTER to continue...");
            ReadKey();
            Clear();

            WriteLine(starwarsDad.Question);
            input = ReadLine();
            WriteLine("Your answer is: " + input + ".");
            WriteLine("The correct answer is false. Darth Vader is Luke's father.");
            WriteLine("Press ENTER to continue...");
            ReadKey();
            Clear();

            WriteLine(animalCrossing.Question);
            input = ReadLine();
            WriteLine("Your answer is: " + input + ".");
            WriteLine("The correct answer is true. Animal Crossing New Horizons continues to sell more copies during these times!");
            WriteLine("Press ENTER to continue...");
            ReadKey();
            Clear();

            WriteLine(boondocksThe.Question);
            input = ReadLine();
            WriteLine("Your answer is: " + input + ".");
            WriteLine("The correct answer is Woodcrest.");
            WriteLine("Press ENTER to continue...");
            ReadKey();
            Clear();

            WriteLine(spongebobFriend.Question);
            input = ReadLine();
            WriteLine("Your answer: " + input + ".");
            WriteLine("The correct answer is Patrick Star.");
            WriteLine("Press ENTER to continue...");
            ReadKey();
            Clear();

            WriteLine(johnWick.Question);
            input = ReadLine();
            WriteLine("Your answer: " + input + ".");
            WriteLine("The correct answer is Keanu Reeves.");


            WriteLine("That's all! Thanks for playing trivia!");
            WriteLine("Press ENTER to continue to exit!!");
            ReadKey();
            Clear();



            //add statements here for gameee
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: TheKnechtion/TriviaGame
        private void Play()
        {
            //Character Name
            //Player input and instructions
            Console.WriteLine("Please enter your name.");
            playerone.name = Console.ReadLine();

            Console.WriteLine("Welcome to the game " + playerone.name + "! ");
            Console.WriteLine("Answer each question correctly to gain points. Good luck, and have fun!");
            Console.WriteLine("Press ENTER to continue");

            //Questions and answers
            TriviaItem item1 = new TriviaItem();
            TriviaItem item2 = new TriviaItem();
            TriviaItem item3 = new TriviaItem();
            TriviaItem item4 = new TriviaItem();
            TriviaItem item5 = new TriviaItem();

            //add color to questions
            ReadLine();
            Clear();
            WriteLine("Question 1:");
            item1.question = "What is your quest?";
            item1.answer   = "I seek the holy grail";
            item2.question = "What game was estimated to be installed on more computers worldwide than Microsoft’s 95?";
            item2.answer   = "Doom";
            item3.question = "In Monty Python's The Holy Grail, what is the first gift requested by The Nights Who Say 'Ni' to pass through the woods?";
            item3.answer   = "shrubbery";
            item4.question = "On what Year did humanity first land on the moon?";
            item4.answer   = "1969";
            item5.question = "What is the tallest building in the world?";
            item5.answer   = "Burj Khalifa";

            //Console.WriteLine("The correct Answers is " + Answer1 +".");

            ForegroundColor = ConsoleColor.Cyan;
            WriteLine(item1.question);
            ResetColor();

            String s;

            s = ReadLine();
            if (s == item1.answer)
            {
                playerone.score = playerone.score + 1;
            }
            WriteLine("The correct answer is " + item1.answer + ". Your answer was " + s);
            WriteLine("Press ENTER to continue.");
            ReadLine();
            Clear();

            WriteLine("Question 2:");
            ForegroundColor = ConsoleColor.Yellow;
            WriteLine(item2.question);
            ResetColor();

            s = ReadLine();
            if (s == item2.answer)
            {
                playerone.score = playerone.score + 1;
            }
            WriteLine("The correct answer is " + item2.answer + ". Your answer was " + s);
            WriteLine("Press ENTER to continue.");
            ReadLine();
            Clear();

            WriteLine("Question 2:");
            ForegroundColor = ConsoleColor.Blue;
            WriteLine(item3.question);
            ResetColor();

            s = ReadLine();
            if (s == item3.answer)
            {
                playerone.score = playerone.score + 1;
            }
            WriteLine("The correct answer is " + item3.answer + ". Your answer was " + s);
            WriteLine("Press ENTER to continue.");
            ReadLine();
            Clear();

            WriteLine("Question 4:");
            ForegroundColor = ConsoleColor.Red;
            WriteLine(item4.question);
            ResetColor();

            s = ReadLine();
            if (s == item4.answer)
            {
                playerone.score = playerone.score + 1;
            }
            WriteLine("The correct answer is " + item4.answer + ". Your answer was " + s);
            WriteLine("Press ENTER to continue.");
            ReadLine();
            Clear();

            WriteLine("Question 5:");
            ForegroundColor = ConsoleColor.Green;
            WriteLine(item5.question);
            ResetColor();

            s = ReadLine();
            if (s == item5.answer)
            {
                playerone.score = playerone.score + 1;
            }
            WriteLine("The correct answer is " + item5.answer + ". Your answer was " + s);
            WriteLine("Press ENTER to continue.");
            ReadLine();
            Clear();
            // add int counter for points
            //Goal of 5 of 5 points Keep track with int
            WriteLine("" + playerone.name + " got " + playerone.score + "/5 correct.");
            WriteLine("Press ENTER to exit the game.");
        }