Example #1
0
                                                                     
 public void AddSwimmer(Registrant swimmer) 

                                                                     {
                                                                         //if (Registrants[numOfRegistrants].RegistrationNumer == swimmer.RegistrationNumer)
                                                                         //{
                                                                         //    throw new Exception("Swimmer " + Registrants[numOfRegistrants].Name + " " + Registrants[numOfRegistrants].RegistrationNumer + "is already entered");
                                                                         //}
                                                                         //else
                                                                         //{
                                                                         //    registrants[numOfRegistrants++] = swimmer;

                                                                         //}
                                                                         if (Registrants.Contains(swimmer))
                                                                         {
                                                                             throw new Exception("Swimmer " + swimmer.Name + ", " + swimmer.RegistrationNumber + ", is already entered");
                                                                         }
                                                                         else
                                                                         {
                                                                             registrants[numOfRegistrants++] = swimmer;
                                                                         }
                                                                     }
Example #2
0
 
 public void Seed(Registrant swimmer, int noOfHeat, int noOfLane) 

 {
     
            for (int i = 0; i < NumOfRegistrants; i++)
     {
         
            {
             
                if (Registrants[i].RegistrationNumber == swimmer.RegistrationNumber)
             {
                 
 EventInfo[i].Heat = noOfHeat;
                 EventInfo[i].Lane = noOfLane; 

             }
             

         }
     }
     

 }
        public void Load(string fileName, string delimiter)
        {
            int        regNo;
            DateTime   date;
            long       phone;
            TextReader reader = new StreamReader(fileName);
            string     line   = reader.ReadLine();

            string[] fields;
            while (line != null)
            {
                try
                {
                    fields = line.Split(Convert.ToChar(delimiter));
                    for (int i = 0; i < number; i++)
                    {
                        if (fields[1] == "")
                        {
                            throw new Exception("Invalid swimmer record. Invalid swimmer name:  \n\t" + line);
                        }
                        else
                        if (!DateTime.TryParse(fields[2], out date))
                        {
                            throw new Exception("Invalid swimmer record. Birth date is inalid: \n\t" + line);
                        }
                        else if (!long.TryParse(fields[7], out phone))
                        {
                            throw new Exception("Invalid swimmer record. Phone number wrong format: \n\t" + line);
                        }
                        else if (!int.TryParse(fields[0], out regNo))
                        {
                            throw new Exception("Invalid swimmer record. Invalid registration number: \n\t" + line);
                        }
                        else if (GetByRegNum(Convert.ToInt32(fields[0])) != null)
                        {
                            if (Swimmers.Contains(GetByRegNum(Convert.ToInt32(fields[0]))))

                            {
                                throw new Exception("Invalid swimmer record. Swimmer with the registration number already exists: \n\t" + line);
                            }
                            else
                            {
                                Address    address    = new Address(fields[3], fields[4], fields[5], fields[6]);
                                Registrant newSwimmer = new Registrant(Convert.ToInt32(fields[0]), fields[1], Convert.ToDateTime(fields[2]), address, Convert.ToUInt32(fields[7]));
                                Add(newSwimmer);
                            }
                        }
                    }
                    Address    address1    = new Address(fields[3], fields[4], fields[5], fields[6]);
                    Registrant newSwimmer1 = new Registrant(Convert.ToInt32(fields[0]), fields[1], Convert.ToDateTime(fields[2]), address1, Convert.ToUInt32(fields[7]));
                    Add(newSwimmer1);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                finally
                {
                    if (Swimmers[number] != null)
                    {
                        ++number;
                        reader.Close();
                    }
                }
                line = reader.ReadLine();
            }
        }
Example #4
0
                                                                   //public void AddSwimmer(Registrant swimmer)
                                                                   //{
                                                                   //    if (numOfRegistrants < MAX_NUM_OF_REGISTRANTS)
                                                                   //    {
                                                                   //        if ((swimmer.Club == null) || (Registrants[numOfRegistrants++].RegistrationNumer != swimmer.RegistrationNumer))
                                                                   //        {
                                                                   //            Registrants[numOfRegistrants++] = swimmer;
                                                                   //            swimmer.Club = this;
                                                                   //        }
                                                                   //        else if (Registrants[numOfRegistrants++].RegistrationNumer == swimmer.RegistrationNumer)
                                                                   //        {
                                                                   //            throw new Exception("already assigned to " + Registrants[numOfRegistrants++].Club.Name);
                                                                   //        }

                                                                   //    }
                                                                   //    else
                                                                   //    {
                                                                   //        throw new Exception("Cannot register more than 20");
                                                                   //    }
                                                                   //}
                                                                   public void AddSwimmer(Registrant swimmer)
                                                                   {
                                                                       if (numOfRegistrants < MAX_NUM_OF_REGISTRANTS)
                                                                       {
                                                                           //if (Registrants[numOfRegistrants++].RegistrationNumber != swimmer.RegistrationNumber)
                                                                           //{

                                                                           //    Registrants[numOfRegistrants++] = swimmer;
                                                                           //    swimmer.Club = this;
                                                                           //}
                                                                           if (!Registrants.Contains(swimmer))
                                                                           {
                                                                               Registrants[numOfRegistrants++] = swimmer;
                                                                               swimmer.Club = this;
                                                                           }
                                                                           else
                                                                           {
                                                                               throw new Exception("Swimmer already assigned to " + Registrants[numOfRegistrants++].Club.Name);
                                                                           }
                                                                       }
                                                                       else
                                                                       {
                                                                           throw new Exception("Cannot register more than 20");
                                                                       }
                                                                   }