예제 #1
0
파일: StartUp.cs 프로젝트: viewless/SoftUni
        static void Main(string[] args)
        {
            string[] input    = Console.ReadLine().Trim().Split();
            string[] urlInput = Console.ReadLine().Trim().Split();

            ICallable  smartphone      = new Smartphone();
            ICallable  stationaryPhone = new StationaryPhone();
            IBrowsable browsable       = new Smartphone();


            for (int i = 0; i < input.Length; i++)
            {
                if (input[i].Length < 10)
                {
                    Console.WriteLine(stationaryPhone.Call(input[i]));
                }
                else
                {
                    Console.WriteLine(smartphone.Call(input[i]));
                }
            }

            for (int i = 0; i < urlInput.Length; i++)
            {
                Console.WriteLine(browsable.Browse(urlInput[i]));
            }
        }
        static void Main(string[] args)
        {
            string[]        numbers         = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries);
            string[]        sites           = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries);
            Smartphone      smartphone      = new Smartphone();
            StationaryPhone stationaryPhone = new StationaryPhone();

            foreach (var number in numbers)
            {
                try
                {
                    if (number.Length == 10)
                    {
                        Console.WriteLine(smartphone.Call(number));
                    }
                    else if (number.Length == 7)
                    {
                        Console.WriteLine(stationaryPhone.Call(number));
                    }
                    else
                    {
                        throw new InvalidNumberException();
                    }
                }
                catch (InvalidNumberException ine)
                {
                    Console.WriteLine(ine.Message);
                }
            }

            foreach (var url in sites)
            {
                try
                {
                    Console.WriteLine(smartphone.Browse(url));
                }
                catch (InvalidURLException iurle)
                {
                    Console.WriteLine(iurle.Message);
                }
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            string[] numbers = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).ToArray();
            string[] urls    = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).ToArray();

            Smartphone      smartphone      = new Smartphone();
            StationaryPhone stationaryPhone = new StationaryPhone();

            foreach (string number in numbers)
            {
                try
                {
                    string result = number.Length == 10
                        ? smartphone.Call(number)
                        : stationaryPhone.Call(number);

                    Console.WriteLine(result);
                }
                catch (InvalidOperationException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            foreach (string url in urls)
            {
                try
                {
                    string result = stationaryPhone.Browse(url);

                    Console.WriteLine(result);
                }
                catch (InvalidOperationException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }