Example #1
0
        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);
        }
Example #2
0
        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);
        }