Beispiel #1
0
 public override void BindContent(Animal dolphin)
 {
     DolphinForm._dolphin = (Dolphin)dolphin;
     name.Text            = _dolphin.Name;
     age.Text             = _dolphin.Age.ToString();
     location.Text        = _dolphin.Location;
     speed.Text           = _dolphin.Speed.ToString();
 }
Beispiel #2
0
 public DolphinForm()
 {
     InitializeComponent();
     _dolphin        = new Dolphin();
     name.Text       = _dolphin.Name;
     location.Text   = _dolphin.Location;
     speed.Text      = _dolphin.Speed.ToString();
     this.ControlBox = false;
 }
Beispiel #3
0
 private void Dolphin_Click(object sender, EventArgs e)
 {
     try
     {
         if (IsValid(SwimmersAge.Text, SwimmersSpeed.Text))
         {
             Dolphin d = new Dolphin(SwimmersName.Text, int.Parse(SwimmersAge.Text), SwimmersLocation.Text, int.Parse(SwimmersSpeed.Text));
             ListOfAnimal.Add(d);
             ChooseAnimal.Items.Add(d);
             List <TextBox> LT = new List <TextBox>();
             LT.Add(SwimmersName);
             LT.Add(SwimmersAge);
             LT.Add(SwimmersLocation);
             LT.Add(SwimmersSpeed);
             ClearFields(LT);
         }
     }
     catch (Exception ex)
     { }
 }
Beispiel #4
0
        public static void ValidateDolphin(ref Dolphin dolphin, string name, string age, string location, string speed)
        {
            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(@"[\w]{1,15}");
            Match loc = reg.Match(location.Trim());

            if (loc.Value == "")
            {
                ValidateError("location");
                return;
            }

            reg = new Regex(@"[\d]{1,2}");
            Match sp = reg.Match(speed.Trim());

            if (sp.Value == "")
            {
                ValidateError("speed");
                return;
            }
            dolphin.Name     = na.Value;
            dolphin.Age      = int.Parse(ag.Value);
            dolphin.Location = loc.Value;
            dolphin.Speed    = int.Parse(sp.Value);
            dolphin.IsFish   = false;
        }
Beispiel #5
0
 public static void ConfigDolphin(Dolphin dolp, string name, string age, string location, string speed)
 {
     ValidateDolphin(ref dolp, name, age, location, speed);
 }