Exemplo n.º 1
0
 public void AddSwimmer(Swimmer aSwimmer)
 {
     Swimmers.Add(aSwimmer);
     if (ClubsManager.Clubs.Contains(aSwimmer.Club) || aSwimmer.Club == null)
     {
     }
     else
     {
         ClubsManager.Clubs.Add(aSwimmer.Club);
     }
 }
Exemplo n.º 2
0
 public void AddSwimmer(Swimmer aSwimmer)
 {
     if (aSwimmer.Club == null)
     {
         aSwimmer.Club = this;
     }
     else
     {
         throw new Exception($"{aSwimmer.Name} already assigned to {aSwimmer.Club.Name}");
     }
 }
Exemplo n.º 3
0
        private Swimmer processSwimmerRecord(string aRecord, string delimiter)
        {
            Address addr;

            string[] values;
            values = aRecord.Split(delimiter[0]);
            addr   = new Address(values[3], values[4], values[5], values[6]);
            DateTime dob;

            if (!DateTime.TryParse(values[2], out dob))
            {
                throw new Exception("Invalid Swimmer record. Birth date is invalid:\n\t" + aRecord);
            }
            uint sid;

            if (!uint.TryParse(values[0], out sid))
            {
                throw new Exception("Invalid Swimmer record. Invalid registration number:\n\t" + aRecord);
            }
            ulong phn;

            if (!ulong.TryParse(values[7], out phn))
            {
                throw new Exception("Invalid Swimmer record. Phone number wrong format:\n\t" + aRecord);
            }

            if (values.Length < 9)
            {
                throw new Exception("Invalid Swimmer record. Not enough swimmer fields:\n\t" + aRecord);
            }
            if (values[1] == "")
            {
                throw new Exception("Invalid Swimmer record. Invalid swimmer name:\n\t" + aRecord);
            }

            foreach (Swimmer c in Swimmers)
            {
                if (c.Id == sid)
                {
                    throw new Exception("Invalid Swimmer record. Swimmer with the registration number already exists:\n\t" + aRecord);
                }
            }
            Swimmer swimmer;

            swimmer = new Swimmer(sid, values[1], dob, addr, phn);
            //  Club toAssign;
            uint clbnum = 0;

            if (uint.TryParse(values[8], out clbnum) && clbnum != 0)
            {
                foreach (Club clb in ClubsManager.Clubs)
                {
                    if (clbnum == clb.ClubNumber)
                    {
                        swimmer.Club = clb;
                    }
                }
            }

            return(swimmer);
        }