Пример #1
0
 public void AddTrakedCitizen(Citizen citizen)
 {
     TrakedCitizens.Add(citizen);
     if (citizen.GetState())
     {
         PositiveCitizens.Add(citizen);
     }
 }
Пример #2
0
        public void SwitchCitizenState(Citizen citizen, bool ToPositive)
        {
            if (!TrakedCitizens.Contains(citizen))
            {
                throw new ApplicationException("This citizen is not traked");
            }
            else if (TrakedCitizens.Contains(citizen) && !ToPositive)
            {
                throw new ApplicationException("This citizen is already non-positive");
            }
            else if (ToPositive && PositiveCitizens.Contains(citizen))
            {
                throw new ApplicationException("This citizen is already positive");
            }

            if (ToPositive)
            {
                PositiveCitizens.Add(citizen);
                if (!citizen.GetState())
                {
                    citizen.ChangeState();
                }
                foreach (Citizen contact in GlobalContacts[citizen])
                {
                    contact.ContactWithPositive = true;
                }
            }
            else
            {
                PositiveCitizens.Remove(citizen);
                if (citizen.GetState())
                {
                    citizen.ChangeState();
                }
            }
        }