Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- namespace InterfaceIPerson
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] phNumbers = Console.ReadLine().Split(' ');
- string[] webAddresses = Console.ReadLine().Split(' ');
- Smartphone sf = new Smartphone();
- foreach (var number in phNumbers)
- {
- Console.WriteLine(sf.CallOther(number));
- }
- foreach (var address in webAddresses)
- {
- Console.WriteLine(sf.BrowseInWeb(address));
- }
- }
- }
- class Smartphone : ICallable, IBrowsable
- {
- public string CallOther(string number)
- {
- string pat = @"^\d+$";
- Regex reg = new Regex(pat);
- if (reg.IsMatch(number))
- {
- return "Calling... " + number;
- }
- else
- {
- return "Invalid number!";
- }
- // is valid return Browsing: number
- // not valid return Invalid URL!
- throw new NotImplementedException();
- }
- public string BrowseInWeb(string webAdr)
- {
- string pat = @"^\D+$";
- Regex reg = new Regex(pat);
- if (reg.IsMatch(webAdr))
- {
- return "Browsing: " + webAdr + "!";
- }
- else
- {
- return "Invalid URL!";
- }
- throw new NotImplementedException();
- }
- }
- interface ICallable
- {
- string CallOther(string number);
- }
- interface IBrowsable
- {
- string BrowseInWeb(string webAdr);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment