Beispiel #1
0
        static void Main(string[] args)
        {
            var numbers = Console.ReadLine().Split().ToArray();

            var webSites = Console.ReadLine().Split().ToArray();

            ISmartphone smartphone = new Smartphone();

            IStationaryPhone stationaryPhone = new StationaryPhone();

            for (int i = 0; i < numbers.Length; i++)
            {
                try
                {
                    if (numbers[i].Length == 10)
                    {
                        smartphone.Call(numbers[i]);
                    }
                    else if (numbers[i].Length == 7)
                    {
                        stationaryPhone.Dialing(numbers[i]);
                    }
                }

                catch (ArgumentException ae)
                {
                    Console.WriteLine(ae.Message);
                }
            }

            for (int i = 0; i < webSites.Length; i++)
            {
                try
                {
                    smartphone.Browse(webSites[i]);
                }
                catch (ArgumentException ae)
                {
                    Console.WriteLine(ae.Message);
                }
            }

            if (webSites.Length == 0)
            {
                Console.WriteLine("Invalid URL!");
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var inputNumber = Console.ReadLine().Split();
            var inputURL    = Console.ReadLine().Split();

            foreach (var number in inputNumber)
            {
                char[] numberChar = number.ToCharArray();

                if (numberChar.Any(char.IsLetter))
                {
                    Console.WriteLine("Invalid number!");
                    continue;
                }

                if (number.Length == 10)
                {
                    Smartphone smartphone = new Smartphone();
                    smartphone.Calling(number);
                }

                if (number.Length == 7)
                {
                    StationaryPhone stationaryPhone = new StationaryPhone();
                    stationaryPhone.Dialing(number);
                }
            }

            foreach (var url in inputURL)
            {
                char[] urlChar = url.ToCharArray();

                if (urlChar.Any(char.IsDigit))
                {
                    Console.WriteLine("Invalid URL!");
                    continue;
                }

                Smartphone smartphone = new Smartphone();
                smartphone.Browsing(url);
            }
        }