private void CallNumbers(string[] phoneNumbers) { foreach (var number in phoneNumbers) { try { if (number.Length == 7) { writer.WriteLine(stationaryPhone.Call(number)); } else if (number.Length == 10) { writer.WriteLine(smartPhone.Call(number)); } else { throw new InvalidNumberException(); } } catch (InvalidNumberException ine) { writer.WriteLine(ine.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); } } }
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()); }
static void Main() { var mySmartPhone = new SmartPhone(); mySmartPhone.Call("123-123-123"); mySmartPhone.TakePicture(); ((IGameConsole)mySmartPhone).Play("Super Mario"); ((IPlayer)mySmartPhone).Play("We_are_the_champions.mp3"); }
void UseSmartPhone(SmartPhone smartPhone) { // Cannot access private property 'Name' here Console.WriteLine(smartPhone.Name); // Cannot access explicit implementation of 'IMp3Player.Play' smartPhone.Play(); // You can send the phone to the method that accepts an IMp3Player though PlaySong(smartPhone); // This works fine. You are sure to get the Phone name here. Console.WriteLine(((IPhone)smartPhone).Name); // This works fine, since the Call is public in SmartPhone. smartPhone.Call(); }
static void Main(string[] args) { //ISP Console.WriteLine("\n-------ISP-----------\n"); Landline landline = new Landline(); landline.Call(); SmartPhone smartPhone = new SmartPhone(); smartPhone.Call(); smartPhone.TakePhoto(); //LCP Console.WriteLine("\n-------LCP-----------\n"); List <IRunning> runners = new List <IRunning>() { new Human(), new Horse() }; Console.WriteLine("Running..."); foreach (var runner in runners) { runner.Run(); } //OCP Console.WriteLine("\n-------OCP-----------\n"); Transport car = new Car(); car.Move(); Transport plane = new Plane(); plane.Move(); Console.ReadKey(); }
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; } } }
public void TestPhone1() { testPhone.Call(); Assert.IsTrue(testPhone.OnCall); }