Ejemplo n.º 1
0
        /// <summary>
        /// "Flatten" method, returns all available flavors
        /// </summary>
        public void DisplayCalories()
        {
            var sodas = new Dictionary <string, int>();

            foreach (var cola in Colas.AvailableFlavors)
            {
                sodas.Add(cola.GetType().Name, cola.Calories);
            }
            sodas.Add(LemonLime.GetType().Name, LemonLime.Calories);

            foreach (var rootbeer in RootBeers.AvailableFlavors)
            {
                sodas.Add(rootbeer.GetType().Name, rootbeer.Calories);
            }

            Console.WriteLine("Calories:");
            foreach (var soda in sodas)
            {
                Console.WriteLine(soda.Key + ": " + soda.Value.ToString() + " calories.");
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var colas = new Cola(210);

            colas.Flavors.Add(new VanillaCola(215));
            colas.Flavors.Add(new CherryCola(210));

            var lemonLime = new LemonLime(185);

            var rootBeers = new RootBeer(195);

            rootBeers.Flavors.Add(new VanillaRootBeer(200));
            rootBeers.Flavors.Add(new StrawberryRootBeer(200));

            var sodaWater = new SodaWater(180);

            sodaWater.Flavors.Add(colas);
            sodaWater.Flavors.Add(lemonLime);
            sodaWater.Flavors.Add(rootBeers);

            sodaWater.DisplayCalories();

            Console.ReadKey();
        }
Ejemplo n.º 3
0
 public SodaDispenser()
 {
     Colas     = new Colas();
     LemonLime = new LemonLime(190);
     RootBeers = new RootBeers();
 }