Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- namespace NumberGuesser
- {
- class Program
- {
- static void Main(string[] args)
- {
- String[] lessthan = { "<", "less", "under", "less than", "less then", "small", "smaller", "lower", "low", "go lower", "down" };
- String[] morethan = { ">", "more", "over", "more than", "more then", "big", "bigger", "higher", "high", "go higher", "up" };
- String[] equalthan = { "=", "==", "yes", "equal", "exactly", "correct", "right", "perfect", "great", "excellent", "indeed", "equal to" };
- String[] affirmative = { "yes", "y", "ye", "yea", "sure", "ok", "okay", "why not", "affirmative", "alright", "I guess", "please" };
- String[] negative = { "no", "nah", "nope", "naw", "argh", "negative" };
- Console.WriteLine("Welcome, {0}", Environment.UserName);
- while (true)
- {
- Console.WriteLine("Please guess a number between 1 and 100 (but don't tell me!)");
- Console.WriteLine("Press any key when you're ready...");
- Console.ReadKey(true);
- int guess = 50;
- int guesses = 0;
- int off = 25;
- Console.Write("I");
- while (true)
- {
- Console.Write("s it greater than, equal to or less than");
- Thread.Sleep(400);
- Console.Write(".");
- Thread.Sleep(400);
- Console.Write(".");
- Thread.Sleep(400);
- Console.Write(".");
- Thread.Sleep(1000);
- Console.WriteLine(" {0}?", guess);
- String response = Console.ReadLine();
- int cont = 0;
- foreach (String ans in lessthan)
- {
- if (response.ToLower().Contains(ans))
- {
- guess -= off;
- off /= 2;
- cont = 1;
- ++guesses;
- break;
- }
- }
- if (cont == 0)
- {
- foreach (String ans in morethan)
- {
- if (response.ToLower().Contains(ans))
- {
- guess += off;
- off /= 2;
- cont = 1;
- ++guesses;
- break;
- }
- }
- }
- if (off == 0) off = 1;
- if (cont == 0)
- {
- foreach (String ans in equalthan)
- {
- if (response.ToLower().Contains(ans))
- {
- cont = 2;
- break;
- }
- }
- }
- switch (cont)
- {
- case 0:
- Console.Write("I don't understand what you just said!\nI");
- break;
- case 1:
- Console.Write("If it's not that, then i");
- break;
- case 2:
- ++guesses;
- Console.WriteLine("\n\nSo your number was {0}, eh? You never stood a chance. It only took me {1} guesse{2}!", guess, guesses, guesses == 1 ? "" : "s");
- break;
- }
- if (cont == 2)
- break;
- }
- Console.WriteLine("\n\n\nWould you like to play again?");
- int status = 0;
- do
- {
- String resp = Console.ReadLine();
- foreach (String ans in affirmative)
- {
- if (resp.ToLower().Contains(ans))
- {
- Console.Clear();
- Console.WriteLine("Okay!\n\n");
- status = 1;
- break;
- }
- }
- if (status == 0)
- {
- foreach (String ans in negative)
- {
- if (resp.ToLower().Contains(ans))
- {
- Console.WriteLine("Alright, I'll see you around!\n\n\t(Press any key)");
- status = 2;
- break;
- }
- }
- }
- if (status != 0)
- break;
- Console.WriteLine("I'm sorry, what do you mean?");
- } while (true);
- if (status == 2) break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment