예제 #1
0
 static void Pay()
 {
     while (true)
     {
         Console.WriteLine("Please Pay {0:C}", _coffeeService.Total());
         Console.Write(">>");
         string  input   = Console.ReadLine();
         decimal payment = 0;
         if (decimal.TryParse(input, out payment))
         {
             var result = _coffeeService.CompleteOrderAndPay(payment);
             if (result.PaymentStatus == PaymentStatus.Success)
             {
                 Console.WriteLine("Thank you for your payment, your change is {0:C}", result.Change);
                 return;
             }
             else if (result.PaymentStatus == PaymentStatus.InsufficientFunds)
             {
                 Console.WriteLine("You have not paid enough to cover your bill.");
             }
             else if (result.PaymentStatus == PaymentStatus.InvalidAmount)
             {
                 Console.WriteLine("The amount you entered was invalid.");
             }
         }
     }
 }