void GetSickInLightForm() { if (HeavyForm) { throw new DiseaseException("Already sick in heavyform!"); } else { LightForm = true; CurrentState = DiseaseForm.Light; } }
void GetSickInHeavyForm() { if (LightForm) { throw new DiseaseException("Already sick in lightform!"); } else { HeavyForm = true; CurrentState = DiseaseForm.Heavy; } }
public void GetWellForOneLevel() { if (HeavyForm) { HeavyForm = false; LightForm = true; CurrentState = DiseaseForm.Light; } else if (LightForm) { LightForm = false; CurrentState = DiseaseForm.Healthy; } else { throw new DiseaseException("Already healthy!"); } }
public Human() { CurrentState = DiseaseForm.Healthy; LightForm = false; HeavyForm = false; }
void ChangePeopleState(ref List <Human> wellPeople, ref List <Human> sickPeople, int count, DiseaseForm form, bool allSick = false) { var r = new Random(); if (form != DiseaseForm.Healthy) { count += sickPeople.Count; while (sickPeople.Count != count && wellPeople.Count != 0) { int index = r.Next(wellPeople.Count); if (wellPeople[index].CurrentState == DiseaseForm.Healthy) { wellPeople[index].GetSickerForOneLevel(); if (wellPeople[index].CurrentState != form) { wellPeople[index].GetSickerForOneLevel(); } sickPeople.Add(wellPeople[index]); wellPeople.RemoveAt(index); } else if (allSick) { if (form == DiseaseForm.Heavy) { wellPeople[index].GetSickerForOneLevel(); sickPeople.Add(wellPeople[index]); wellPeople.RemoveAt(index); } else { wellPeople[index].GetWellForOneLevel(); sickPeople.Add(wellPeople[index]); wellPeople.RemoveAt(index); } } } } else { count += wellPeople.Count; while (wellPeople.Count != count && sickPeople.Count != 0) { int index = r.Next(sickPeople.Count); sickPeople[index].GetWellForOneLevel(); if (sickPeople[index].CurrentState != form) { sickPeople[index].GetWellForOneLevel(); } wellPeople.Add(sickPeople[index]); sickPeople.RemoveAt(index); } } }