示例#1
0
        /// <summary>
        /// Receives the client's choice
        /// and retrieves the product's price.
        /// </summary>
        /// <returns>Price of selected product.</returns>
        /// <exception cref="VendingMachine.Exceptions.SoldOutException">Thrown when product is sold out.</exception>
        /// <param name="i_VendingMachine">Vending machine instance.</param>
        /// <param name="i_Product">Selected product.</param>
        private static int selectProductAndGetPrice(NewVendingMachine i_VendingMachine, eProduct i_Product)
        {
            bool isAvailable = true;

            do
            {
                try
                {
                    if (i_VendingMachine.ProductInventory.getQuantity(i_Product) > 0)
                    {
                        i_VendingMachine.CurrentProduct = i_Product;
                    }
                    else
                    {
                        isAvailable = false;
                        throw new SoldOutException();
                    }
                }
                catch (SoldOutException SoldOut)
                {
                    UIInterface.PrintToCMD(SoldOut.Message);
                }
            }while (!isAvailable);

            return((int)i_Product);
        }
示例#2
0
        private static void invalidMessage()
        {
            string message = string.Format(
                @"Invalid Input!{0}",
                Environment.NewLine);

            UIInterface.PrintToCMD(message);
        }
示例#3
0
        /// <summary>
        /// Prompts the client to enter specific amount of money.
        /// </summary>
        /// <param name="i_Amount">Amount to pay by the client.</param>
        private static void enterAmountMessage(int i_Amount)
        {
            string message = string.Format(
                @"Please enter {1} Shekels:{0} ",
                Environment.NewLine,
                i_Amount);

            UIInterface.PrintToCMD(message);
        }
示例#4
0
        /// <summary>
        /// Prompts the client of the amount left to pay.
        /// </summary>
        /// <param name="i_AmountLeft">Amount left to pay by the client.</param>
        private static void showAmountLeft(int i_AmountLeft)
        {
            string message = string.Format(
                @"You need {0} more shekels to complete the purchase{1}",
                i_AmountLeft,
                Environment.NewLine);

            UIInterface.PrintToCMD(message);
        }
示例#5
0
        /// <summary>
        /// Prompts the client to enter a coin.
        /// </summary>
        /// <returns>String representation of the client's coin.</returns>
        private static string getCoinFromUser()
        {
            string coinFromClient = string.Empty;
            string message        = string.Format(
                @"Please enter coin:{0}",
                Environment.NewLine);

            UIInterface.PrintToCMD(message);
            coinFromClient = UIInterface.GetInputFromUser();

            return(coinFromClient);
        }
示例#6
0
        /// <summary>
        /// Prompts the client to confirm the purchase or get a refund.
        /// </summary>
        /// <returns>Correlating int input.</returns>
        private static int clientConfirmPurchaseOrRefund()
        {
            string userInput;

            string message = string.Format(
                @"Choose 'Confirm' to complete the purchase or 'Refund' to cancel:{0}
 1. Confirm{0}
 2. Refund{0}",
                Environment.NewLine);

            UIInterface.PrintToCMD(message);
            userInput = UIInterface.GetInputFromUser();

            return(int.Parse(userInput));
        }
示例#7
0
 private static void showMessage(string i_message)
 {
     UIInterface.PrintToCMD(i_message);
 }