Abdula_2314124

Untitled

Mar 12th, 2024
1,045
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.71 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Project
  4. {
  5.     class Program
  6.     {
  7.         //bool[] isAlives = { true, false, true };
  8.         static void Main(string[] args)
  9.         {
  10.             Random rnd = new Random();
  11.             Console.WriteLine("Hello, write you question");
  12.             string[] botAnswers = { "Yes", "No", "Maybe", "Lol", "50|50" };
  13.             string userQuestion = Console.ReadLine();
  14.             int randomIndex = rnd.Next(0, botAnswers.Length);
  15.             int randomRightIndex = rnd.Next(0, botAnswers.Length);
  16.             SetUpColor(botAnswers, randomIndex);
  17.             Console.WriteLine(botAnswers[randomIndex]);
  18.             string rightAnswer = SetRigthAnswer(botAnswers, randomRightIndex);
  19.             Console.WriteLine($"Right answer equals {rightAnswer}");
  20.         }
  21.         static string SetRigthAnswer(string[] botAnswers, int randomIndex)
  22.         {
  23.             return botAnswers[randomIndex];
  24.         }
  25.  
  26.         static void SetUpColor(string[] botAnswers, int randomIndex)
  27.         {
  28.             switch (botAnswers[randomIndex])
  29.             {
  30.                 case "Yes":
  31.                     Console.ForegroundColor = ConsoleColor.Red;
  32.                     break;
  33.                 case "No":
  34.                     Console.ForegroundColor = ConsoleColor.Green;
  35.                     break;
  36.                 case "Maybe":
  37.                     Console.ForegroundColor = ConsoleColor.Blue;
  38.                     break;
  39.                 case "Lol":
  40.                     Console.ForegroundColor = ConsoleColor.Magenta;
  41.                     break;
  42.                 case "50|50":
  43.                     Console.ForegroundColor = ConsoleColor.Yellow;
  44.                     break;
  45.             }
  46.         }
  47.     }
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment