static void Main(string[] args) { string number, path, model, endCheck = string.Empty; do { string endInput = "y"; IHappyTicketCounter countModel = null; Console.WriteLine(StartInfo); while (true) { Console.WriteLine(PathInput); path = Console.ReadLine(); try { using (StreamReader sr = new StreamReader(path)) model = sr.ReadLine(); if (model == "Moskow") { countModel = new MoskovCount(); break; } else if (model == "Piter") { countModel = new PiterCount(); break; } else { throw new Exception("File does not consist useful information."); } } catch (FileNotFoundException ex) { Console.WriteLine(ex.Message); } catch (Exception ex) { Console.WriteLine(ex.Message); } } HappyTickets happyTickets = new HappyTickets(countModel); Console.WriteLine(string.Format(Answer, happyTickets.AmountOfHappyTickets)); Console.WriteLine(StartAgain); endCheck = Console.ReadLine(); } while (endCheck.ToLower() == "y"); }
public HappyTickets(IHappyTicketCounter _countModel) { countModel = _countModel; AmountOfHappyTickets = countHappyTickets(); }