public void AddLollipopInList(Lollipop lollipop) { LollipopList.Add(lollipop); if (LollipopAdded != null) { LollipopAdded(lollipop); } Console.WriteLine("lollipop added!"); }
private void button1_Click(object sender, EventArgs e) { //Console.WriteLine("flavor selected : " + comboBoxLollipopSelection.SelectedItem.ToString()); //adding new lollipop to list; decimal quantity = numericUpDown1.Value = 1; string lollipopFlavor = comboBoxLollipopSelection.SelectedItem.ToString(); string cherry = "Cherry"; string lime = "Lime"; if (lollipopFlavor.Contains(cherry)) { Lollipop newLollipop = new Lollipop(lollipopFlavor, 5.30, quantity); m_model.AddLollipopInList(newLollipop); this.Hide(); MainNavigation aMainNavigation = new MainNavigation(m_model); aMainNavigation.Closed += (s, args) => this.Close(); aMainNavigation.Show(); } else if (lollipopFlavor.Contains(lime)) { Lollipop newLollipop = new Lollipop(lollipopFlavor, 4.00, quantity); m_model.AddLollipopInList(newLollipop); this.Hide(); MainNavigation aMainNavigation = new MainNavigation(m_model); aMainNavigation.Closed += (s, args) => this.Close(); aMainNavigation.Show(); } else { Lollipop newLollipop = new Lollipop(lollipopFlavor, 3.89, quantity); m_model.AddLollipopInList(newLollipop); this.Hide(); MainNavigation aMainNavigation = new MainNavigation(m_model); aMainNavigation.Closed += (s, args) => this.Close(); aMainNavigation.Show(); } }