Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Fproject
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] questions =
- {
- "Юніті vs Unreal?",
- "int vs float?",
- "Львівське Різдвяне vs Балтіка?",
- "A vs B?"
- };
- string[] rightAnswers =
- {
- "Unity",
- "inteFLoat",
- "Lvivske",
- "AB"
- };
- Random rnd = new Random();
- var index = rnd.Next(0, questions.Length);
- Game(questions, rightAnswers, rnd, index);
- }
- static void Game(string[] questions, string[] rightAnswers, Random rnd, int index)
- {
- while (true)
- {
- Console.WriteLine(questions[index]);
- int prevIndex = index;
- string userAnswer = Console.ReadLine();
- CheckRightIndex(rightAnswers, rnd, index, userAnswer);
- index = UpdateIndex(questions, rnd, index, prevIndex);
- }
- }
- static void CheckRightIndex(string[] rightAnswers, Random rnd, int index, string userAnswer)
- {
- if (rightAnswers[index].Equals(userAnswer))
- {
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("GOOOD");
- Console.ResetColor();
- }
- else
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("BADDDDDDDDDD");
- Console.ResetColor();
- }
- }
- static int UpdateIndex(string[] questions, Random rnd, int index, int prevIndex)
- {
- while (index == prevIndex)
- {
- index = rnd.Next(0, questions.Length);
- }
- return index;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment