public void AddAllergen(Allergen.AllergenType type) { if (_allergenTypes.Contains(type)) { return; } _allergenTypes.Add(type); }
public Meals GetAllergenFromUSer(Meals meal) { Console.WriteLine("Is the food allergen free?"); Console.WriteLine("Answer Y or N"); var allergens = Enum.GetNames(typeof(Allergen.AllergenType)); foreach (string str in allergens) { if (str != "negative") { Console.WriteLine(); Console.WriteLine(str); bool answer = GetYesOrNoFromUser(); if (answer == true) { Allergen.AllergenType an = (Allergen.AllergenType)Enum.Parse(typeof(Allergen.AllergenType), str); meal.AddAllergen(an); } } } return(meal); }