static void Main(string[] args) { var phone = new Smartphone(); var stationaryPhone = new StationaryPhone(); var phoneNumbers = Console.ReadLine().Split().ToArray(); var urls = Console.ReadLine().Split().ToArray(); for (int i = 0; i < phoneNumbers.Length; i++) { if (phoneNumbers[i].Length == 7 || phoneNumbers[i].Length == 10) { if (phoneNumbers[i].Length == 7) { stationaryPhone.Dial(phoneNumbers[i]); } else { phone.Call(phoneNumbers[i]); } } else { Console.WriteLine("Invalid number!"); } } for (int i = 0; i < urls.Length; i++) { phone.Browse(urls[i]); } }
private static void Browse(string[] urls) { Smartphone smartPhone = new Smartphone(); foreach (var url in urls) { try { Console.WriteLine(smartPhone.Browse(url)); } catch (Exception ex) { Console.WriteLine(ex.Message); } } }
static void Main() { var numbers = Console.ReadLine().Split(' '); var urls = Console.ReadLine().Split(' '); var smartphone = new Smartphone(); foreach (var number in numbers) { Console.WriteLine(smartphone.Call(number)); } foreach (var url in urls) { Console.WriteLine(smartphone.Browse(url)); } }
static void Main(string[] args) { string[] phoneNumbers = Console.ReadLine() .Split(' ', StringSplitOptions.RemoveEmptyEntries); string[] webSites = Console.ReadLine() .Split(' ', StringSplitOptions.RemoveEmptyEntries); StationaryPhone stationaryPhone = new StationaryPhone(); Smartphone smartphone = new Smartphone(); foreach (var number in phoneNumbers) { try { if (number.Length == 7) { stationaryPhone.Call(number); } else if (number.Length == 10) { smartphone.Call(number); } else { throw new ArgumentException("Invalid number!"); } } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } } foreach (var site in webSites) { try { smartphone.Browse(site); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } } }
static void Main(string[] args) { string[] numbers = Console.ReadLine().Split(); string[] urls = Console.ReadLine().Split(); foreach (var number in numbers) { try { if (number.Length == 10) { Smartphone smartphone = new Smartphone(); smartphone.Call(number); } else if (number.Length == 7) { StationaryPhone sp = new StationaryPhone(); sp.Call(number); } else { throw new InvalidNumberException(); } } catch (InvalidNumberException ine) { Console.WriteLine(ine.Message); } } foreach (var url in urls) { try { Smartphone smartphone = new Smartphone(); smartphone.Browse(url); } catch (InvalidURLException iue) { Console.WriteLine(iue.Message); } } }
static void Main(string[] args) { var phoneNumbers = Console.ReadLine().Split(); var urls = Console.ReadLine().Split(); StationaryPhone stationaryPhone = new StationaryPhone(); Smartphone smartphone = new Smartphone(); for (int i = 0; i < phoneNumbers.Length; i++) { try { if (phoneNumbers[i].Length == 7) { Console.WriteLine(stationaryPhone.Call(phoneNumbers[i])); } else if (phoneNumbers[i].Length == 10) { Console.WriteLine(smartphone.Call(phoneNumbers[i])); } else { throw new InvalidPhoneNumberException(); } } catch (InvalidPhoneNumberException ex) { Console.WriteLine(ex.Message); } } for (int i = 0; i < urls.Length; i++) { try { Console.WriteLine(smartphone.Browse(urls[i])); } catch (InvalidUrlException ex) { Console.WriteLine(ex.Message); } } }
static void Main(string[] args) { string[] numbers = Console.ReadLine() .Split(" "); string[] URLs = Console.ReadLine() .Split(" "); Smartphone smartphone = new Smartphone(); StationaryPhone stationaryPhone = new StationaryPhone(); foreach (var number in numbers) { try { if (number.Length == 10) { Console.WriteLine(smartphone.Call(number)); } else { Console.WriteLine(stationaryPhone.Call(number)); } } catch (ArgumentException ae) { Console.WriteLine(ae.Message); } } foreach (var URL in URLs) { try { Console.WriteLine(smartphone.Browse(URL)); } catch (ArgumentException ae) { Console.WriteLine(ae.Message); } } }
static void Main(string[] args) { string[] nums = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries); string[] urls = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries); Smartphone phone = new Smartphone(); StationaryPhone statPhone = new StationaryPhone(); for (int i = 0; i < nums.Length; i++) { if (nums[i].Any(x => !char.IsDigit(x))) { Console.WriteLine("Invalid number!"); } else { if (nums[i].Length == 7) { statPhone.Call(nums[i]); } else { phone.Call(nums[i]); } } } for (int i = 0; i < urls.Length; i++) { if (urls[i].Any(x => char.IsDigit(x))) { Console.WriteLine("Invalid URL!"); } else { phone.Browse(urls[i]); } } }
static void Main(string[] args) { string[] phoneNumbers = Console.ReadLine().Split(); string[] sites = Console.ReadLine().Split(); StationaryPhone stationaryPhone = new StationaryPhone(); Smartphone smartphone = new Smartphone(); foreach (var number in phoneNumbers) { try { string result = number.Length == 10 ? smartphone.Call(number) : stationaryPhone.Call(number); Console.WriteLine(result); } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); } } foreach (var site in sites) { try { string result = smartphone.Browse(site); Console.WriteLine(result); } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); } } }