static void Main() { Hour r = new Hour(); string task = ""; string func = ""; string choice = ""; string ti = ""; string ye = ""; string pa = ""; string co = ""; int yearo = -1; int pasperh = -1; do { Console.WriteLine("\nEnter 'o' to open the file and 'e' to exit."); task = Console.ReadLine(); switch (task) { case "e": r.Exits(); break; case "o": { r.Opens(); Console.WriteLine("\nThe total number of passengers per hour is " + r.TotalPs()); Console.WriteLine("\nThe station(s) that has(have) the minimal number of passengers: "); r.MajorHs(); Console.WriteLine("\nThe station(s) that has(have) the maximum number of words in comment: "); r.WordsInCs(); Console.WriteLine("\n"); do { Console.WriteLine("\n'a' to add new information, 's' to search for editing and deleting and 'e' to exit."); func = Console.ReadLine(); switch (func) { case "e": r.Exits(); task = "e"; break; case "a": { do { Console.WriteLine("\nEnter the title: "); ti = Console.ReadLine(); } while (ti.Length == 0); do { Console.WriteLine("\nEnter the year when station was opened: "); ye = Console.ReadLine(); yearo = Int32.Parse(ye); } while (yearo < 0); do { Console.WriteLine("\nEnter the number of passengers per hour: "); pa = Console.ReadLine(); pasperh = Int32.Parse(pa); } while (pasperh < 0); do { Console.WriteLine("\nEnter the comment: "); co = Console.ReadLine(); } while (co.Length == 0); r.Adds(ti, yearo, pasperh, co); break; } case "s": { int strings = -1; string strins = ""; do { Console.WriteLine("\nEnter the number of string you need: "); strins = Console.ReadLine(); strings = Int32.Parse(strins); } while (strings < 1); strings = strings - 1; r.Searchs(strings); do { Console.WriteLine("\nEnter 'e' to edit, 'd' to delete and 'r' to return."); choice = Console.ReadLine(); switch (choice) { case "r": break; case "e": { string tt = ""; string yy = ""; string pp = ""; string cc = ""; int yeo = -1; int paper = -1; do { Console.WriteLine("\nEnter the title to replace the previous one: "); tt = Console.ReadLine(); } while (tt.Length == 0); do { Console.WriteLine("\nEnter the year when station was opened to replace the previous one: "); yy = Console.ReadLine(); yeo = Int32.Parse(yy); } while (yeo < 0); do { Console.WriteLine("\nEnter the number of passengers per hour to replace the previous one: "); pp = Console.ReadLine(); paper = Int32.Parse(pp); } while (paper < 0); do { Console.WriteLine("\nEnter the comment to replace the previous one: "); cc = Console.ReadLine(); } while (cc.Length == 0); r.Edits(strings, tt, yeo, paper, cc); break; } case "d": { r.Deletes(strings); choice = "r"; break; } default: Console.WriteLine("Try again. ('e' to edit, 'd' to delete and 'r' to return)"); break; } } while (choice != "r"); break; } default: Console.WriteLine("Try again. ('a' to add, 's' to search and 'e' to exit)"); break; } } while (func != "e"); break; } default: Console.WriteLine("Try again. ('o' to open file and 'e' to exit)"); break; } } while (task != "e"); }