Exemple #1
0
        public static void ImportFoods()
        {
            var json  = File.ReadAllText("../../../datasets/foods.json");
            var foods = JsonConvert.DeserializeObject <IEnumerable <FoodDto> >(json);

            FoodStore.AddFoods(foods);
        }
Exemple #2
0
        /// <summary>
        /// Return the total of the specified metric in the diet
        /// </summary>
        /// <param name="metric"></param>
        /// <returns></returns>
        public double GetTotal(string metric)
        {
            double result = 0;

            if (FoodStore is null)
            {
                // check if initial value provided
                otherMetricAmounts.TryGetValue(metric, out result);
            }
            else
            {
                // convert to metric if possible
                var amount = FoodStore.ConvertTo(metric, AmountConsumed);
                if (amount != null)
                {
                    Double.TryParse(result.ToString(), out result);
                }
            }
            return(result);
        }
Exemple #3
0
 public void Dispose()
 {
     cs = null;
     fd = null;
 }
Exemple #4
0
 public void Init()
 {
     cs = new VendingMachine(10, 3, 2, 3, 2, 2);
     fd = new FoodStore();
 }