public Ticket(int[] numbers, LuckyTicketType luckyTicketType) { _numbers = numbers; if (luckyTicketType == LuckyTicketType.Moskow) { _algorithm = new MoskowTicket(); } else if (luckyTicketType == LuckyTicketType.Piter) { _algorithm = new PiterTicket(); } }
public static void Run(string path) { TicketsCollection myTicketsList = new TicketsCollection(); using (StreamReader sr = new StreamReader(path)) { LuckyTicketType luckyTicketType = GetLuckyTicketType(sr.ReadLine().ToUpper()); string buffer = sr.ReadLine(); while (buffer != null) { int[] numbers = Validator.ValidateNumberAndReturnArray(buffer); myTicketsList.Add(new Ticket(numbers, luckyTicketType)); buffer = sr.ReadLine(); } _view.ShowResult($"Count lucky tickets: { myTicketsList.CountOfLuckyTickets().ToString()}"); } }
public static void Run(string path) { TicketsCollection myTicketsList = new TicketsCollection(); using (StreamReader sr = new StreamReader(path)) { LuckyTicketType luckyTicketType = GetLuckyTicketType(sr.ReadLine().ToUpper()); string buffer = sr.ReadLine(); while (buffer != null) { int[] numbers = Validator.ValidateNumberAndReturnArray(buffer); myTicketsList.Add(new Ticket(numbers, luckyTicketType)); buffer = sr.ReadLine(); } UserIterface.Display(myTicketsList); } }