/// <summary>Returns whether this property contains a grocery of given type</summary> public bool HasGrocery(GroceryType groceryType) { foreach (var grocery in groceries) { if (grocery == groceryType) { return(true); } } return(false); }
/// <summary>Remove the value of this property, only set fromSaveFile flag to true when called when called after loading it from a file</summary> public void RemoveGrocery(GroceryType groceryType) { for (int i = groceries.Count - 1; i >= 0; i--) { if (groceries[i] == groceryType) { groceries.RemoveAt(i); break; } } SaveToFile(); }
/// <summary>Returns the price of given grocery type for this grocery property</summary> public double GetPrice(GroceryType groceryType) { for (int i = 0; i < prices.Length; i++) { GroceryPrice price = prices[i]; if (price.Type == groceryType) { return(price.Value); } } return(0.0d); }
/// <summary>Adds the value of this property, only set fromSaveFile flag to true when called when called after loading it from a file</summary> public void AddGrocery(GroceryType groceryType) { groceries.Add(groceryType); SaveToFile(); }