Exemple #1
0
        static void Main(string[] args)
        {
            Coffee normalCoffee = new Coffee(CoffeeSize.Normal);
            Coffee doubleCoffee = new Coffee(CoffeeSize.Double);

            Console.WriteLine("The {0} coffee is {1} ml.", normalCoffee.Size, (int)normalCoffee.Size);
            Console.WriteLine("The {0} coffee is {1} ml.", doubleCoffee.Size, (int)doubleCoffee.Size);
            Console.WriteLine("{0:f2}lv",normalCoffee.CalcPrice(normalCoffee.Size));
        }
Exemple #2
0
 public double CalcPrice(Coffee.CoffeeSize coffeSize)
 {
     switch (coffeSize)
     {
         case CoffeeSize.Small: return 0.20;
         case CoffeeSize.Normal: return 0.30;
         case CoffeeSize.Double: return 0.60;
         case CoffeeSize.Overwhelming: return 1.20;
         default: throw new InvalidOperationException("Unsupported coffee quantity: " + (int)coffeSize);
     }
 }