Advertisement
tane_superior

Untitled

Nov 20th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.98 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace tane_superior_sr3
  8. {
  9.     class Helper
  10.     {
  11.         public static bool ShutdownChecker()
  12.         {
  13.             int initResp = (int)default;
  14.             bool success = (bool)default;
  15.             bool response = (bool)default;
  16.             while (!success)
  17.             {
  18.                 initResp = IntReader();
  19.                 if (initResp == 1)
  20.                 {
  21.                     success = true;
  22.                     response = false;
  23.                 }
  24.                 else
  25.                 {
  26.                     if (initResp == 2)
  27.                     {
  28.                         success = true;
  29.                         response = true;
  30.                     }
  31.                     else Console.WriteLine("Incorrect input, try again");
  32.                 }
  33.             }
  34.             return response;
  35.         }
  36.         public static int IntReader()
  37.         {
  38.             int num = (int)default;
  39.             bool success = (bool)default;
  40.             while (!success)
  41.             {
  42.                 if (int.TryParse(Console.ReadLine(), out num) && num > 0 && num < 69420)
  43.                 {
  44.                     success = true;
  45.                 }
  46.                 else
  47.                 {
  48.                     Console.WriteLine("Incorrect input, try again");
  49.                 }
  50.             }
  51.             return num;
  52.         }
  53.     }
  54.     class Cat
  55.     {
  56.         public static Random rng = new Random();
  57.         string name;
  58.         public string meow;
  59.         string[] meowArray = new string[7]{"meow", "Meow.", "mEOW", "nigga", "le meau", "myat", "Epstein didnt kill himself"};
  60.  
  61.         public Cat(int n)
  62.         {
  63.             name = $"Cat{n+1}";
  64.             int sample = rng.Next(0, n);
  65.             meow = this[sample];
  66.         }
  67.         public string this[int index]
  68.         {
  69.             get
  70.             {
  71.                 string kostyl = null;
  72.                 try
  73.                 {
  74.                     kostyl = meowArray[index];
  75.                 }
  76.                 catch(Exception ex)
  77.                 {
  78.                     Console.WriteLine(ex);
  79.                 }
  80.                 return kostyl;
  81.             }
  82.         }
  83.     }
  84.     class Program
  85.     {
  86.         static void Main(string[] args)
  87.         {
  88.             bool shutdown = (bool)default;
  89.             while (!shutdown)
  90.             {
  91.                 Console.WriteLine("enter N");
  92.                 int n = Helper.IntReader();
  93.  
  94.                 Cat[] kittyArray = new Cat[n];
  95.                 for (int i = 0; i < n; i++)
  96.                     kittyArray[i] = new Cat(i);
  97.  
  98.                 Console.WriteLine("kote myaukayut \n");
  99.                 for (int i = 0; i < n; i++)
  100.                     Console.WriteLine($"{kittyArray[i].meow}\n");
  101.  
  102.                 Console.WriteLine("Continue? 1 to proceed, 2 to exit");
  103.                 shutdown = Helper.ShutdownChecker();
  104.             }
  105.         }
  106.     }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement