예제 #1
0
 static void Main(string[] args)
 {
     try
     {
         var provider = CommandArgumentsNumberProvider.Create(args);
         var calc     = new Calculator(provider);
         var sum      = calc.Sum();
         Console.WriteLine(sum);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
예제 #2
0
 public static INumberProvider Create(string[] args)
 {
     try
     {
         int a        = Convert.ToInt32(args[0]);
         int b        = Convert.ToInt32(args[1]);
         var provider = new CommandArgumentsNumberProvider(a, b);
         return(provider);
     }
     catch
     {
         throw new NumberException("Can't convert to int32");
     }
 }