예제 #1
0
 public Purchase InputPurchase()
 {
     {
         Console.WriteLine(INPUT_TYPE);
         string type = inputer.InputStrings();
         Console.WriteLine(INPUT_NAME);
         string name = inputer.InputStrings();
         Console.WriteLine(INPUT_QUANTITY);
         int quantity = inputer.InputQuantity();
         if (quantity.GetType() != typeof(Int32))
         {
             throw new FormatException();
         }
         if (quantity < 0)
         {
             throw new NegativeQuantityException(NEGATIVE_QUANTITY_EXCEPTION);
         }
         Console.WriteLine(INPUT_PRICE);
         decimal price = inputer.InputPrice();
         if (price.GetType() != typeof(Decimal))
         {
             throw new FormatException();
         }
         if (price < 0)
         {
             throw new NegativePriceException(NEGATIVE_PRICE_EXCEPTION);
         }
         Purchase purchase = new Purchase(type, name, quantity, price);
         return(purchase);
     }
 }