private void MakeDrink(Drink drink, int sugars, Temperature temperature) { if (_BeverageQuantityChecker.IsEmpty(drink)) { _EmailNotifier.NotifyMissingDrink(drink); _Messages.Add("There is not enough water or milk."); return; } drink.Sugars = sugars; drink.Temperature = temperature; _DrinksMade.Add(drink); _ReportingTool.AddDrink(drink); // How do I make a "Spy" class? }
public string Translate(Order order) { var beverage = _beverageReferential.GetBeverage(order.BeverageKind); if (_beverageQuantityChecker.IsEmpty(beverage.Code)) { _emailNotifier.NotifyMissingDrink(beverage.Code); return($"M:Shortage for {beverage.Name}"); } if (ReturnNotEnoughMoneyWhenNecessary(order, beverage, out var message)) { return(message); } var extraHotCode = !beverage.IsCold && order.ExtraHot ? "h" : string.Empty; TakeOrder(order); return(BuildMessage(order, beverage, extraHotCode)); }
public bool TryExecuteCommand(string command) { InstructionParser.TryParse(command, out var instruction); switch (instruction) { case DrinkInstruction drinkInstruction: _moneyModule.DrinkOrder = drinkInstruction.DrinkType; if (_beverageQuantityChecker.IsEmpty(drinkInstruction.DrinkType)) { _emailNotifier.NotifyMissingDrink(drinkInstruction.DrinkType); Message = "There is not enough water or milk"; return(false); } Message = _moneyModule.GetOrderTotalMessage(); _moneyModule.RequestMoney(); if (!_moneyModule.IsOrderPaid()) { Message = _moneyModule.GetOrderNotPaidMessage(); return(false); } Drink = GetDrink(drinkInstruction); return(true); case MessageInstruction messageInstruction: Message = GetMessage(messageInstruction); return(true); case ErrorMessageInstruction errorMessageInstruction: Message = ErrorMessage(errorMessageInstruction); return(false); default: return(false); } }
public string Order(DrinkCommand command, double credits = 0) { if (command != null) { if (_beverageQuantityChecker != null && _emailNotifier != null && _beverageQuantityChecker.IsEmpty(command.GetType().ToString())) { _emailNotifier.NotifyMissingDrink(command.GetType().ToString()); return(new MessageCommand( String.Format("The drink is missing, a notification has been sent.") ).CommandString()); } else if (credits >= command.Price) { IncreaseCounter(command); IncreaseCreditCounter(command.Price); return(command.CommandString()); } return(new MessageCommand( String.Format("Missing {0} credits.", command.Price - credits) ).CommandString()); } return(null); }