Exemple #1
0
        public void Run()
        {
            string[] phoneNumbers = Console.ReadLine().Split();
            string[] urls         = Console.ReadLine().Split();

            foreach (var phoneNumber in phoneNumbers)
            {
                try
                {
                    Console.WriteLine(smartPhone.Calling(phoneNumber));
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            foreach (var url in urls)
            {
                try
                {
                    Console.WriteLine(smartPhone.Browse(url));
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
    static void Main()
    {
        SmartPhone smartPhone = new SmartPhone();

        string[] phoneNumbersToCall = Console.ReadLine().Split();
        foreach (string phoneNumber in phoneNumbersToCall)
        {
            try
            {
                smartPhone.Call(phoneNumber);
            }
            catch (ArgumentException exception)
            {
                Console.WriteLine(exception.Message);
            }
        }
        string[] webSitesToBrowse = Console.ReadLine().Split();
        foreach (string webSite in webSitesToBrowse)
        {
            try
            {
                smartPhone.Browse(webSite);
            }
            catch (ArgumentException exception)
            {
                Console.WriteLine(exception.Message);
            }
        }
    }
Exemple #3
0
    public static void Main()
    {
        var numbers = Console.ReadLine().Split().ToList();
        var urls    = Console.ReadLine().Split().ToList();

        var phone = new SmartPhone(numbers, urls);

        Console.WriteLine(phone.Call());
        Console.WriteLine(phone.Browse());
    }
 private void BrowseSites(string[] sites)
 {
     foreach (var site in sites)
     {
         try
         {
             writer.WriteLine(smartPhone.Browse(site));
         }
         catch (InvalidURLMessage ium)
         {
             writer.WriteLine(ium.Message);
         }
     }
 }
        static void Main(string[] args)
        {
            var numbers = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
            var urls    = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();

            foreach (var number in numbers)
            {
                try
                {
                    SmartPhone currentPhone = new SmartPhone();
                    currentPhone.Number = number;
                    currentPhone.Call();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    continue;
                }
            }
            if (urls.Count == 0)
            {
                Console.WriteLine("Browsing: !");
            }
            foreach (var url in urls)
            {
                try
                {
                    SmartPhone currentPhone = new SmartPhone();
                    currentPhone.Url = url;
                    currentPhone.Browse();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    continue;
                }
            }
        }