Ejemplo n.º 1
0
        public override void Prepare()
        {
            var message = "";

            if (Toppings.Any(t => t.Type == ToppingType.Milk))
            {//Asssuming log file is for barista
                message = "You cannot select Milk with Ice Tea.";
                throw new InvalidOperationException(
                          $"warning: IceTea was not prepared, reason: " +
                          $"Milk was selected as topping. {DateTime.Now.ToString("dd/MM/yyyy h:mm tt")}");
            }

            message = "We are preparing the following drink for you: " + Description;

            if (Toppings.Any(t => t.Type == ToppingType.Sugar))
            {
                message += "with sugar";
            }
            else
            {
                message += "without sugar";
            }

            if (Toppings.Any(t => t.Type == ToppingType.Chocolate))
            {
                message += "with chocolate";
            }
            else
            {
                message += "without chocolate";
            }
            HasBeenPrepared = true;
            Console.WriteLine(message);
        }
Ejemplo n.º 2
0
        public override void Prepare()
        {
            string message = "We are preparing the following drink for you: " + Description;

            if (Toppings.Any(t => t.Type == ToppingType.Milk))
            {
                message += "with milk";
            }
            else
            {
                message += "without milk";
            }

            if (Toppings.Any(t => t.Type == ToppingType.Sugar))
            {
                message += "with sugar";
            }
            else
            {
                message += "without sugar";
            }

            if (Toppings.Any(t => t.Type == ToppingType.Chocolate))
            {
                message += "with chocolate";
            }
            else
            {
                message += "without chocolate";
            }
            HasBeenPrepared = true;
            Console.WriteLine(message);
        }
Ejemplo n.º 3
0
        protected string PrepareToppings()
        {
            if (!Toppings.Any())
            {
                return(string.Empty);
            }

            var toppingsNames = Toppings.Select(t => t.Name).ToList();

            return($" with {string.Join(", ", toppingsNames)}");
        }
        private double CalculatePrice()
        {
            Price = 100;
            if (Size == Sizes.Big)
            {
                Price += 200;
            }
            else if (Size == Sizes.Medium)
            {
                Price += 100;
            }

            if (Toppings.Any())
            {
                foreach (var t in Toppings)
                {
                    Price += (int)t;
                }
            }
            return(Price);
        }