Esempio n. 1
0
        public void Run()
        {
            var phoneNumbers = Console.ReadLine()
                               .Split(" ", StringSplitOptions.RemoveEmptyEntries);
            var sites = Console.ReadLine()
                        .Split(" ", StringSplitOptions.RemoveEmptyEntries);


            foreach (var phone in phoneNumbers)
            {
                if (phone.Length == 10)
                {
                    ICall call = new Smartphone();
                    Console.WriteLine(call.Calling(phone));
                }
                else
                {
                    ICall dialing = new StationaryPhone();
                    Console.WriteLine(dialing.Calling(phone));
                }
            }

            foreach (var site in sites)
            {
                IBrowse browse = new Smartphone();
                Console.WriteLine(browse.Browsing(site));
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            string[] numbers  = Console.ReadLine().Split(" ").ToArray();
            string[] websites = Console.ReadLine().Split(" ").ToArray();

            for (int i = 0; i < numbers.Length; i++)
            {
                try
                {
                    if (numbers[i].Length == 7)
                    {
                        StationaryPhone phone = new StationaryPhone();
                        Console.WriteLine(phone.Calling(numbers[i]));
                    }
                    else
                    {
                        Smartphone smartphone = new Smartphone();
                        Console.WriteLine(smartphone.Calling(numbers[i]));
                    }
                }
                catch (ArgumentException error)
                {
                    Console.WriteLine(error.Message);
                }
            }
            for (int i = 0; i < websites.Length; i++)
            {
                try
                {
                    Smartphone smartphone = new Smartphone();
                    Console.WriteLine(smartphone.Browsing(websites[i]));
                }
                catch (ArgumentException error)
                {
                    Console.WriteLine(error.Message);
                }
            }
        }