public static void Main() { Riddle river = new Riddle("I have a mouth but do not speek, I have a bed but do not sleep, I run everywhere but go nowhere, what am I?", "river"); Riddle nose = new Riddle("I can run but not walk. Wherever I go, thought follows behind. What am I?", "nose"); Riddle sponge = new Riddle("I have holes in my top and bottom, my left and right, and my middle. But I still hold water. What am I?", "sponge"); Riddle david = new Riddle("David’s parents have three sons: Snap, Crackle, and what’s the name of the third son?", "david"); Riddle fire = new Riddle("Give me food, and I will live; give me water, and I will die. What am I?", "fire"); Riddle corn = new Riddle("It stalks the countryside with ears that can’t hear. What is it?", "corn"); Riddle seven = new Riddle("I am an odd number. Take away a letter and I become even. What number am I?", "seven"); Riddle envelope = new Riddle("What begins with an “e” and only contains one letter?", "envelope"); Riddle queue = new Riddle("What word is pronounced the same if you take away four of its five letters?", "queue"); Riddle coffin = new Riddle("The man who invented it doesn't want it. The man who bough it doesn't need it. The man who needs it dosen't know it. What is it?", "coffin"); while (Riddle.riddles.Count > 0) { Console.WriteLine(Riddle.AskRiddle()); string userAnswer = (Console.ReadLine()).ToLower(); string expectedAnswer = Riddle.CheckAnswer(); if (expectedAnswer == userAnswer) { Riddle.RemoveRiddle(); Console.WriteLine("You answered correct!"); } else { Console.WriteLine("Sorry the answer was: " + expectedAnswer); Console.WriteLine("NOM NOM NOM"); break; } } Console.WriteLine("You've solved all my puzzles! You get to live!"); }
public static void Main() { Riddle firstRiddle = new Riddle("What has to be broken before you can use it?", "egg", "Egg"); Riddle secondRiddle = new Riddle("I shave every day, but my beard stays the same. What am I?", "barber", "Barber"); Riddle thirdRiddle = new Riddle("The more of this there is, the less you see. What is it?", "darkness", "Darkness"); Riddle fourthRiddle = new Riddle("What has many keys but can't open a single lock?", "piano", "Piano"); List <Riddle> RiddleList = new List <Riddle>() { firstRiddle, secondRiddle, thirdRiddle, fourthRiddle }; bool temp = true; int asdf = RiddleList.Count; for (int i = 0; i < asdf; i++) { Random rnd = new Random(); int index = rnd.Next(RiddleList.Count - 1); Console.WriteLine(RiddleList[index].NewRiddle); string userAnswer = Console.ReadLine(); if (!RiddleList[index].Correct(userAnswer)) { Console.WriteLine("Time for a snack!"); temp = false; break; } RiddleList.Remove(RiddleList[index]); } if (temp) { Console.WriteLine("You beat me!"); } }
public static void Main() { Riddle riddle = new Riddle(); Riddle.BeSpooky(); riddle.SetRiddle("Why?", "because"); riddle.AskRiddle(); }
public static void Main() { Riddle questionOne = new Riddle("I’m tall when I’m young, and I’m short when I’m old. What am I?", "a candle"); Console.WriteLine(questionOne.Question); Console.WriteLine("what is your answer"); string answer = Console.ReadLine(); if (answer.ToLower() == (questionOne.Answer).ToLower()) { Console.WriteLine("you won"); } else { Console.WriteLine("you got eaten"); } }
public static void Main() { Riddle riddle1 = new Riddle("Which creature walks on four legs in the morning, two legs at midday, and three legs in the evening?", "A Human"); Riddle riddle2 = new Riddle("A box without hinges, key, or lid, yet golden treasure inside is hid", "An Egg"); Riddle riddle3 = new Riddle("30 white horses on a red hill, first they champ, then they stamp then they stand still", "Teeth"); Console.WriteLine("Guess the answer to the riddle to avoid being eaten!"); void CreateQuestion() { Riddle currentRiddle = riddle3; Console.WriteLine(currentRiddle.Question); string userAnswer = Console.ReadLine(); currentRiddle.CheckAnswer(userAnswer); } CreateQuestion(); }