Exemplo n.º 1
0
        /// <summary>
        /// When clicking the button to add drinks, run through every combo box and run
        /// the method to create drink objects for every drink at once.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddDrinks_Click(object sender, EventArgs e)
        {
            drinks.Clear();

            if (nudDrinksCoke.Value > 0)
            {
                drinks.Add(DrinkLogic.CreateDrink("Coke", (int)nudDrinksCoke.Value));
            }

            if (nudDrinksPepsi.Value > 0)
            {
                drinks.Add(DrinkLogic.CreateDrink("Pepsi", (int)nudDrinksPepsi.Value));
            }

            if (nudDrinksDietCoke.Value > 0)
            {
                drinks.Add(DrinkLogic.CreateDrink("Diet Coke", (int)nudDrinksDietCoke.Value));
            }

            if (nudDrinks7Up.Value > 0)
            {
                drinks.Add(DrinkLogic.CreateDrink("7-Up", (int)nudDrinks7Up.Value));
            }

            if (nudDrinksFanta.Value > 0)
            {
                drinks.Add(DrinkLogic.CreateDrink("Fanta", (int)nudDrinksFanta.Value));
            }

            if (nudDRinksTango.Value > 0)
            {
                drinks.Add(DrinkLogic.CreateDrink("Tango", (int)nudDRinksTango.Value));
            }

            PopulateDrinkListBox();
            btnAddDrinks.Text = "Update Drink(s)";
        }