public void AddAlergy(Alergies alergie) { if (this.TestAlergy(alergie)) { Console.WriteLine("The patient already have this alergy."); } else { int numarAlergie = (int)alergie; int codulAlergieiCurente = (int)Math.Pow(2, numarAlergie); score = score + codulAlergieiCurente; } }
public bool TestAlergy(Alergies alergie) { int numarAlergie = (int)alergie; int codAlergie = (int)Math.Pow(2, numarAlergie); if (score < codAlergie) { return(false); } else { string binary = Convert.ToString(score, 2); if (binary[binary.Length - (numarAlergie + 1)] == '1') { return(true); } else { return(false); } } }