public Event(EventDistance distance, Stroke stroke) { Distance = distance; Stroke = stroke; Name = Convert.ToString(Distance) + "" + Convert.ToString(Stroke); SwimMeet = new SwimMeet(); EventRegistrantList = new Registrant[100]; EventRegistrantSwim = new Swim[100]; NoOfRegistrantInEvent = 0; }
public void AddSwimmer(Registrant registrant) { Swims = new Swim(); if (NoOfRegistrantInEvent > 0) { int match = 0; for (int i = 0; i < NoOfRegistrantInEvent; i++) { Registrant aRegistrantName = EventRegistrantList[i]; if (aRegistrantName.Name == registrant.Name) { match++; throw new Exception("Swimmer " + registrant.Name + "," + registrant.RegistrationNumber + " already entered " + this.Name + "\n"); } } if (match == 0) { EventRegistrantList[NoOfRegistrantInEvent] = registrant; EventRegistrantSwim[NoOfRegistrantInEvent] = Swims; if (NoOfRegistrantInEvent + 1 > SwimMeet.NumberOfLane) { EventRegistrantSwim[NoOfRegistrantInEvent].NumberOfLane = 1; EventRegistrantSwim[NoOfRegistrantInEvent].NumberOfTheHeat += 1; } else { EventRegistrantSwim[NoOfRegistrantInEvent].NumberOfLane = NoOfRegistrantInEvent + 1; } NoOfRegistrantInEvent++; } } else { EventRegistrantList[NoOfRegistrantInEvent] = registrant; EventRegistrantSwim[NoOfRegistrantInEvent] = this.Swims; EventRegistrantSwim[NoOfRegistrantInEvent].NumberOfLane = NoOfRegistrantInEvent + 1; NoOfRegistrantInEvent++; } }