Пример #1
0
        public static void ValidateButter(ref Butterfly butter, string name, string age, bool CanFly, string wings)
        {
            Regex reg = new Regex(@"[\w]{1,15}");
            Match na  = reg.Match(name.Trim());

            if (na.Value == "")
            {
                ValidateError("name");
                return;
            }
            reg = new Regex(@"[\d]{1,2}");
            Match ag = reg.Match(age.Trim());

            if (ag.Value == "")
            {
                ValidateError("age");
                return;
            }
            reg = new Regex(@"[\d]{1,1}");
            Match wi = reg.Match(wings.Trim());

            if (wi.Value == "")
            {
                ValidateError("wings");
                return;
            }
            butter.Name          = na.Value;
            butter.Age           = int.Parse(ag.Value);
            butter.CanFly        = CanFly;
            butter.WingsQuantity = int.Parse(wi.Value);
            butter.IsBird        = true;
        }
Пример #2
0
 public override void BindContent(Animal butter)
 {
     ButterflyForm._butter = (Butterfly)butter;
     name.Text             = _butter.Name;
     age.Text    = _butter.Age.ToString();
     fly.Checked = _butter.CanFly;
     wings.Text  = _butter.WingsQuantity.ToString();
 }
Пример #3
0
 public ButterflyForm()
 {
     InitializeComponent();
     _butter         = new Butterfly();
     name.Text       = _butter.Name;
     age.Text        = _butter.Age.ToString();
     fly.Checked     = _butter.CanFly;
     wings.Text      = _butter.WingsQuantity.ToString();
     this.ControlBox = false;
 }
Пример #4
0
 public ButterflyForm()
 {
     _butter = new Butterfly();
     InitializeComponent();
     name.Text   = _butter.Name;
     age.Text    = _butter.Age.ToString();
     fly.Checked = _butter.CanFly;
     wings.Text  = _butter.WingsQuantity.ToString();
     nameP       = "";
     ageP        = 0;
     flyP        = false;
     wingsP      = 0;
 }
Пример #5
0
 private void Butterfly_Click(object sender, EventArgs e)
 {
     try
     {
         if (IsValid(FlyersAge.Text, FlyersWingsQuantity.Text))
         {
             Butterfly bu = new Butterfly(FlyersName.Text, int.Parse(FlyersAge.Text), bool.Parse(FlyersCanFly.Text), int.Parse(FlyersWingsQuantity.Text));
             ListOfAnimal.Add(bu);
             ChooseAnimal.Items.Add(bu);
             List <TextBox> LT = new List <TextBox>();
             LT.Add(FlyersName);
             LT.Add(FlyersAge);
             LT.Add(FlyersWingsQuantity);
             ClearFields(LT);
         }
     }
     catch (Exception ex) { }
 }
Пример #6
0
 public static void ConfigButter(Butterfly butter, string name, string age, bool CanFly, string wings)
 {
     ValidateButter(ref butter, name, age, CanFly, wings);
 }