示例#1
0
        public Leaven MakingLeavenObject()
        {
            try
            {
                if (Convert.ToInt32(water.Text) < 0)
                {
                    throw new Exception("Please, enter count of water more than zero");
                }
                if (material.SelectedIndex == -1)
                {
                    throw new Exception("Please, choose the type of material");
                }
                if (Convert.ToInt32(materialCount.Text) < 0)
                {
                    throw new Exception("Please, enter count of materials more than zero");
                }
                if (Convert.ToInt32(yeald.Text) < 0)
                {
                    throw new Exception("Please, enter count of yeald more than zero");
                }
                if (Convert.ToInt32(sugar.Text) < 0)
                {
                    throw new Exception("Please, enter count of sugar more than zero");
                }

                Leaven temp = new Leaven(Convert.ToInt32(water.Text), material.SelectedIndex, Convert.ToInt32(materialCount.Text), Convert.ToInt32(yeald.Text), Convert.ToInt32(sugar.Text));
                return(temp);
            }
            finally
            {
            }
        }
示例#2
0
 public void ChangingLeavenElement(Leaven element)
 {
     water.Text            = element.CountOfWater.ToString();
     material.SelectedItem = element.RawMaterials;
     materialCount.Text    = element.CountOfMaterials.ToString();
     yeald.Text            = element.CountOfYeast.ToString();
     sugar.Text            = element.CountOfSugar.ToString();
 }
示例#3
0
 public Kvass(string name, double volume, Leaven leavenType)
 {
     Name        = name;
     Volume      = volume;
     Carbonation = true;
     LeavenType  = leavenType;
     TypeName    = "Kvass";
 }
示例#4
0
 public Beer(string name, double volume, int percent, Leaven leavenType)
 {
     Name             = name;
     Volume           = volume;
     PercentOfAlcohol = percent;
     LeavenType       = leavenType;
     TypeName         = "Beer";
 }
示例#5
0
        private void MakingObject(object sender, EventArgs e)
        {
            try
            {
                Leaven newLeaven = MakingLeavenObject();
                if (newLeaven == null)
                {
                    throw new Exception("Please, enter leave fields ");
                }

                if ((nameBox.Text.Trim()).Length == 0)
                {
                    throw new Exception("Please, enter name of drink");
                }
                if ((Convert.ToInt32(percentBox.Text) > 70) || (Convert.ToInt32(percentBox.Text) < 0))
                {
                    throw new FormatException();
                }
                Beer template = new Beer(nameBox.Text.Trim(), Convert.ToDouble(volume.Value), Convert.ToInt32(percentBox.Text), newLeaven);
                ChooseAction(template);
            }
            catch (FormatException exept)
            {
                MessageBox.Show("Please enter correct percent of alcohol");
            }
            catch (ArgumentOutOfRangeException exept)
            {
            }
            catch (Exception exept)
            {
                if (exept.Message.Length > 0)
                {
                    MessageBox.Show(exept.Message);
                }
            }
        }
示例#6
0
 private void MakingObject(object sender, EventArgs e)
 {
     try
     {
         Leaven newLeaven = MakingLeavenObject();
         if ((nameBox.Text.Trim()).Length == 0)
         {
             throw new Exception("Please, enter name of drink");
         }
         Kvass template = new Kvass(nameBox.Text.Trim(), Convert.ToDouble(volume.Value), newLeaven);
         ChooseAction(template);
     }
     catch (FormatException exept)
     {
         MessageBox.Show("Please, enter correct information about leaven ");
     }
     catch (ArgumentOutOfRangeException exept)
     {
     }
     catch (Exception exept)
     {
         MessageBox.Show(exept.Message);
     }
 }
示例#7
0
        public override Drinks Deserialize(string[] words)
        {
            Leaven temp = new Leaven(Convert.ToInt32(words[3]), Convert.ToInt32(words[4]), Convert.ToInt32(words[5]), Convert.ToInt32(words[6]), Convert.ToInt32(words[7]));

            return(new Kvass(words[1], Convert.ToDouble(words[2]), temp));
        }