Esempio n. 1
0
 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(percentBox.Text) > 90) || (Convert.ToInt32(percentBox.Text) < 0))
         {
             throw new Exception("Please, enter correct percent of alcohol");
         }
         if ((Convert.ToInt32(ageBox.Text) > 200) || (Convert.ToInt32(ageBox.Text) < 0))
         {
             throw new Exception("Please, enter correct age of cognac");
         }
         Cognac template = new Cognac(nameBox.Text.Trim().ToString(), Convert.ToDouble(volume.Value), Convert.ToInt32(percentBox.Text), Convert.ToInt32(ageBox.Text));
         ChooseAction(template);
     }
     catch (FormatException exept)
     {
         MessageBox.Show("Please, enter correct percent of alcohol or age ");
     }
     catch (ArgumentOutOfRangeException exept)
     {
     }
     catch (Exception exept)
     {
         MessageBox.Show(exept.Message);
     }
 }
Esempio n. 2
0
        public override bool Equals(Drinks v1)
        {
            Cognac other = v1 as Cognac;

            if ((other != null) && (this.Name == other.Name) && (this.Volume == other.Volume) && (this.PercentOfAlcohol == other.PercentOfAlcohol) && (this.Age == other.Age))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
        public override void ChangingElement(Panel panel, Drinks element, DChange del)
        {
            Cognac temp = element as Cognac;

            nameBox.Text    = element.Name;
            volume.Value    = Convert.ToDecimal(element.Volume);
            percentBox.Text = temp.PercentOfAlcohol.ToString();
            ageBox.Text     = temp.Age.ToString();

            this.save.Text = "Change Object";

            delToAdd    = null;
            delToChange = del;
        }