public override void ChangingElement(Panel panel, Drinks element, DChange del) { Lemonade temp = element as Lemonade; nameBox.Text = element.Name; volume.Value = Convert.ToDecimal(element.Volume); CountOfLemons.Value = Convert.ToDecimal(temp.CountOfLemon); this.save.Text = "Change Object"; delToAdd = null; delToChange = del; }
public override bool Equals(Drinks v1) { Lemonade other = v1 as Lemonade; if ((other != null) && (this.Name == other.Name) && (this.Volume == other.Volume) && (this.CountOfLemon == other.CountOfLemon)) { return(true); } else { return(false); } }
private void MakingObject(object sender, EventArgs e) { try { if ((nameBox.Text.Trim()).Length == 0) { throw new Exception("Please, enter name of drink"); } if ((Convert.ToInt32(CountOfLemons.Text) > 20)) { throw new Exception("So much lemos, it very sour :D"); } Lemonade template = new Lemonade(nameBox.Text.Trim().ToString(), Convert.ToDouble(volume.Value), Convert.ToInt32(CountOfLemons.Text)); ChooseAction(template); } catch (ArgumentOutOfRangeException exept) { } catch (Exception exept) { MessageBox.Show(exept.Message); } }