Example #1
0
 /// <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);
 }
Example #2
0
 /// <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();
 }
Example #3
0
        /// <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);
        }
Example #4
0
 /// <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();
 }