private void Play() { player = new Player(); Console.WriteLine("Please enter your name"); //string playerName = Console.ReadLine(); player.name = Console.ReadLine(); Console.WriteLine("Welcome " + player.name); int score = 0; string input = " "; //add statements here for game //Creates item1 and gives question and answer TriviaItem item1 = new TriviaItem(); item1.setAnswers(); item1.setQuestions(); for (int i = 0; i < 10; i++) { Console.WriteLine(item1.getQuestion(i)); input = Console.ReadLine(); input = input.ToUpper(); //makes input all caps so that caps don't matter for correct answer Console.WriteLine("The correct answer was " + item1.getAnswer(i)); if (input == item1.getAnswer(i)) //Checks to see if answer is correct { score = score + 1; //Adds +1 to score if answer was correct Console.WriteLine("Congralations, you're answer was correct"); } else { Console.WriteLine("Sorry, you're answer was incorrect"); } Console.WriteLine("Current score: " + score + "/10"); //Displays current score Console.WriteLine("Press any key to continue"); Console.ReadKey(); Console.Clear(); } //End of Quiz Console.WriteLine("End of quiz, " + player.name); Console.WriteLine("You're score: " + score + "/10"); if (score == 10) //Checks to see if you got a perfect score { Console.WriteLine("Congratulations, " + player.name + "! You got a perfect score"); } if (score == 0) //Checks to see if you got no answers { Console.WriteLine("You didn't get any of 'em! Try harder next time, bub."); } Console.ReadKey(); }
public void Execute() { //Game Intro Title = gameName; WriteLine("Welcome to " + gameName); WriteLine("Instructions: Type your answer and hit enter to continue."); WriteLine("What is your name?"); string input = ReadLine(); WriteLine("Hello " + input + " Press enter to start"); ReadKey(); Clear(); //Question 1 TriviaItem classOverview = new TriviaItem(); classOverview.QuestionText = "What element types can you choose from when starting pokemon?"; classOverview.Answer = "Fire, Water, and Grass"; WriteLine(classOverview.Show()); input = ReadLine(); WriteLine("You answered " + input + " and the correct answer was " + classOverview.Answer); WriteLine("Press enter to continue"); ReadKey(); Clear(); //Question 2 classOverview.QuestionText = "How many pokemon generations are there currently?"; classOverview.Answer = "7"; WriteLine(classOverview.Show()); input = ReadLine(); WriteLine("You answered " + input + "the correct answer was " + classOverview.Answer); WriteLine("Press enter to continue"); ReadKey(); Clear(); //Question 3 classOverview.QuestionText = "What type of attack has no effect against ground type pokemon?"; classOverview.Answer = "Electric"; WriteLine(classOverview.Show()); input = ReadLine(); WriteLine("You answered " + input + " the correct answer was " + classOverview.Answer); WriteLine("Press enter to continue"); ReadKey(); Clear(); //End of Game WriteLine("Thanks for playing"); WriteLine("Press enter to exit"); ReadKey(); }
private static TriviaItem[] TriviaItemsAssignment() { TriviaItem[] triviaItems = new TriviaItem[10]; triviaItems[0] = new TriviaItem { question = "What do you call a group of flying Geese?", answer = "Skein" }; triviaItems[1] = new TriviaItem { question = "What do you call a group of walking Geese?", answer = "Gaggle" }; triviaItems[2] = new TriviaItem { question = "Do Geese mourn for their lost companions?", answer = "Yes" }; triviaItems[3] = new TriviaItem { question = "What is the term for a male goose?", answer = "Gander" }; triviaItems[4] = new TriviaItem { question = "Where do geese come from historically?", answer = "Africa or China" }; triviaItems[5] = new TriviaItem { question = "Where were geese first domesticated?", answer = "Egypt" }; triviaItems[6] = new TriviaItem { question = "How old can a goose get? Please type your answer as text", answer = "Twenty" }; triviaItems[7] = new TriviaItem { question = "Under which classification do geese fall based on diet?", answer = "Herbivore" }; triviaItems[8] = new TriviaItem { question = "Which sport traditionally used goose feathers in the making of their ball?", answer = "Golf" }; triviaItems[9] = new TriviaItem { question = "What do geese love most?", answer = "Weed" }; return(triviaItems); }
public void Start() { Console.Title = "Trivia game by Michael"; Random rnd = new Random(); //setting up random number generator int num = rnd.Next(); Goal = 1000; Player player1 = new Player(); //initilazing the player setting score to zero and having player pick a name. player1.Score = 0; player1.Name = player1.GiveName(); Console.WriteLine($"Welcome, {player1.Name}, to a hand picked trivia quiz with question made specifically for you. \nPress any key to continue."); Console.ReadKey(); Console.Clear(); Console.WriteLine("You will recieve questions from a random list. If you get them right you recieve their worth in points. If you get them wrong you will lose half their worth in points."); Console.WriteLine("There is no timer so don't be afraid to take your time. Also if you find any bugs please tell me."); Console.WriteLine($"Your goal is {Goal} points. Press any key to begin the trivia."); Console.ReadKey(); Console.Clear(); TriviaItem[] TriviaItems = new TriviaItem[10]; TriviaItems[0] = new TriviaItem("What year was the compact disk first shown on television", "1982", "Obscure technology history", 100); //start of the trivia questions TriviaItems[1] = new TriviaItem("What is the bit depth of the red book standard for cds", "16", "Sound technology facts", 200); TriviaItems[2] = new TriviaItem("What weighs the same as a witch", "Duck", "movie references", 100); TriviaItems[3] = new TriviaItem("Who killed Dumbledoor", "Snape", "Movie Spoilers", 100); TriviaItems[4] = new TriviaItem("Some cats are allergic to people. True or False", "True", "Obscure facts", 150); TriviaItems[5] = new TriviaItem("What is the national animal of scotland", "Unicorn", "Obscure facts", 50); TriviaItems[6] = new TriviaItem("What does M&M stand for", "Mars and Murrie", "Very Obscure facts", 500); TriviaItems[7] = new TriviaItem("The odds of getting a royal flush are 1 in..", "649740", "Statistics", 500); TriviaItems[8] = new TriviaItem("Pepsi was the first soft drink in space. True or False", "False", "Obsure facts", 200); TriviaItems[9] = new TriviaItem("Only ___ mosquitos will bite you. Male or Female", "Female", "bugs", 100); //end of the trivia questions while (player1.Score < Goal) //loops questions until the player's score is higher than the goal of the game { string skip = "y"; while (skip != "n") { num = rnd.Next(TriviaItems.Count()); //selects a random number for the random trivia question //Console.WriteLine(num); //writes the random number for testing purposes. Console.WriteLine($"Your next question is about {TriviaItems[num].Topic} and is worth {TriviaItems[num].Worth} points\nWould you like to skip this question (y/n)"); ConsoleKeyInfo key = Console.ReadKey(); skip = Convert.ToString(key.KeyChar); Console.Clear();// this section allows you to skip questions if you don't like the topic of them. } TriviaItems[num].DisplayQuestion(); //displays the random question if (TriviaItems[num].CheckAnswer(Console.ReadLine()) == true) // checks if the answer was correct and gives/ takes away points accordingly { player1.AddPoints(TriviaItems[num].Worth); Console.WriteLine($"Correct you just gained { TriviaItems[num].Worth} poins and are now at {player1.Score} total points."); } else { player1.RemovePoints(TriviaItems[num].Worth / 2); Console.WriteLine($"Incorrect. The correct answer was {TriviaItems[num].CorrectAnswer}. You lost {TriviaItems[num].Worth / 2} points and are now at {player1.Score} total points."); } if (player1.Score < Goal) { Console.WriteLine("Press any key to continue on the the next question"); } else { Console.WriteLine("Congradulations. You win. I have yet to figue out a reward so take these free internet points."); Console.WriteLine("Press any button to close the program."); } Console.ReadKey(); Console.Clear(); } }