Ejemplo n.º 1
0
        public static void Main()
        {
            string[] phoneInput = Console.ReadLine().Split().ToArray();
            string[] siteInput  = Console.ReadLine().Split().ToArray();

            var stationary = new StationaryPhone();
            var smart      = new Smartphone();


            for (int i = 0; i < phoneInput.Length; i++)
            {
                try
                {
                    if (phoneInput[i].Length == 7)
                    {
                        Console.WriteLine(stationary.CallOtherPhones(phoneInput[i]));
                    }
                    else if (phoneInput[i].Length == 10)
                    {
                        Console.WriteLine(smart.CallOtherPhones(phoneInput[i]));
                    }
                    else
                    {
                        throw new ArgumentException(InvalidMsg.InvalidNumberMsg);
                    }
                }
                catch (ArgumentException ae)
                {
                    Console.WriteLine(ae.Message);
                }
            }

            foreach (var url in siteInput)
            {
                try
                {
                    Console.WriteLine(smart.BrowseW(url));
                }
                catch (ArgumentException ae)
                {
                    Console.WriteLine(ae.Message);
                }
            }
        }
Ejemplo n.º 2
0
        static void Main()
        {
            string[]        inputNum   = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
            string[]        inputSites = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
            Smartphone      smart      = new Smartphone();
            StationaryPhone phone      = new StationaryPhone();

            foreach (var number in inputNum)
            {
                if (!ValidNumber(number))
                {
                    Console.WriteLine("Invalid number!");
                }
                else
                {
                    if (number.Length == 10)
                    {
                        smart.CallOtherPhones(number);
                    }
                    else if (number.Length == 7)
                    {
                        phone.CallOtherPhones(number);
                    }
                }
            }
            foreach (var site in inputSites)
            {
                if (ContainsNum(site))
                {
                    Console.WriteLine("Invalid URL!");
                }
                else
                {
                    smart.Browse(site);
                }
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            var phoneNubmers = Console.ReadLine().Split();

            for (int i = 0; i < phoneNubmers.Length; i++)
            {
                if (!NumberValidation(phoneNubmers[i]))
                {
                    Console.WriteLine("Invalid number!");
                    continue;
                }

                if (phoneNubmers[i].Length == 10)
                {
                    ICallOtherPhones calling = new Smartphone();
                    calling.CallOtherPhones(phoneNubmers[i]);
                }
                else if (phoneNubmers[i].Length == 7)
                {
                    ICallOtherPhones calling = new StationaryPhone();
                    calling.CallOtherPhones(phoneNubmers[i]);
                }
            }

            var websites = Console.ReadLine().Split();

            for (int i = 0; i < websites.Length; i++)
            {
                if (!WebsiteValidation(websites[i]))
                {
                    Console.WriteLine("Invalid URL!");
                    continue;
                }
                IBrowseWeb browsing = new Smartphone();
                browsing.BrowseWeb(websites[i]);
            }
        }