public void Leave(string login) { if (!IsTakenPart(login)) { throw new InvalidOperationException(string.Format("{0} is not taking part in this competition", login)); } Competitors.RemoveAll(c => c.Login == login); }
public string SelectNewLeader() { if (Competitors.Count < 2) { throw new InvalidOperationException("Selecting a new leader is not possible when Competition has less than 2 competitors"); } Competitors.RemoveAll(c => c.Login == Leader); string newLeader = Competitors.Select(c => c.Login).First(); Leader = newLeader; Name = newLeader; return(newLeader); }