static void Main(string[] args) { string[] numbers = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries); string[] sites = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries); Smartphone smartphone = new Smartphone(); StationaryPhone stationaryPhone = new StationaryPhone(); foreach (var number in numbers) { try { if (number.Length == 10) { Console.WriteLine(smartphone.Call(number)); } else if (number.Length == 7) { Console.WriteLine(stationaryPhone.Call(number)); } else { throw new InvalidNumberException(); } } catch (InvalidNumberException ine) { Console.WriteLine(ine.Message); } } foreach (var url in sites) { try { Console.WriteLine(smartphone.Browse(url)); } catch (InvalidURLException iurle) { Console.WriteLine(iurle.Message); } } }
static void Main(string[] args) { string[] numbers = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).ToArray(); string[] urls = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).ToArray(); Smartphone smartphone = new Smartphone(); StationaryPhone stationaryPhone = new StationaryPhone(); foreach (string number in numbers) { try { string result = number.Length == 10 ? smartphone.Call(number) : stationaryPhone.Call(number); Console.WriteLine(result); } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); } } foreach (string url in urls) { try { string result = stationaryPhone.Browse(url); Console.WriteLine(result); } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); } } }