Пример #1
0
        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);
                }
            }
        }
Пример #2
0
        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);
                }
            }
        }
Пример #3
0
        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);
                }
            }
        }
Пример #4
0
        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]);
                }
            }
        }
Пример #5
0
        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);
                }
            }
        }