public void Run() { bool inMenu = true; int command; while (inMenu) { PrintSpaces(); Console.Write(GetMenu()); try { command = Int32.Parse(Console.ReadLine()); } catch (Exception e) { continue; } switch (command) { case 1: Homework h = ReadHomework(); if (h == null) { Console.Write("Incorrect data."); } else { Console.Write(service.AddHomework(h) + "\n"); } break; case 0: inMenu = false; break; } } }