예제 #1
0
        public int ComputeCost(String drink, bool student, int amount)
        {
            if (!menu.ContainsKey(drink))
            {
                throw new Exception("No such drink exists");
            }

            IBeverage beverage = menu[drink];

            if (amount > MAX_NUMBER_OF_DRINKS && beverage.isAmountLimited())
            {
                throw new Exception("Too many drinks, max " + MAX_NUMBER_OF_DRINKS);
            }

            int price = beverage.GetPrice();

            if (student && beverage.isEligableForStudentDiscount())
            {
                price = price - price / STUDENT_DISCOUNT;
            }

            return(price * amount);
        }
예제 #2
0
 public double GetPrice()
 {
     return(_beverage.GetPrice());
 }
예제 #3
0
 public virtual double GetPrice()
 {
     return(DecoratedBeverage.GetPrice());
 }