Advertisement
Abdula_2314124

Untitled

Mar 16th, 2024
527
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Project
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Random rnd = new Random();
  10.  
  11.             while (true)
  12.             {
  13.                 Console.ForegroundColor = ConsoleColor.White;
  14.                 Console.WriteLine("\nHello, write you question");
  15.                 string userQuestion = Console.ReadLine();
  16.                 Console.ForegroundColor = ConsoleColor.Green;
  17.                 Console.WriteLine(GenerateAnswer(userQuestion, rnd));
  18.                 if (Console.ReadKey().KeyChar == 'a')
  19.                 {
  20.                     break;
  21.                 }
  22.             }
  23.         }
  24.  
  25.         static string GenerateAnswer(string question, Random rnd)
  26.         {
  27.             var word = question.Split(" ");
  28.  
  29.             string answer = "";
  30.             var index = rnd.Next(0, word.Length);
  31.             answer += word[index];
  32.  
  33.             return "Yes is " + answer;
  34.         }
  35.     }
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement