I have this code below:
Foood[] food = new Foood[types];
food[0] = new Foood("protein", 2.0);
food[1] = new Foood("vitamins", 3.0);
food[2] = new Foood("Carbonhydrate", 4.0);
and then this
List<Foood> foods = new List<Foood>();
foods.Add(food[0]);
foods.Add(food[1]);
foods.Add(food[2]);
and then this
for (int i = 0; i < days; i++)
{
UpdateCalories(foods);
}
public void UpdateCalories(List<Foood> foodItem)
{
for (int i = 0; i < foodItem.Count; i++)
{
foodItem[i].calories = foodItem[i].calories + 1.1;
}
}
i want to be able to have values for different days before printing
What I have tried:
I have written and pasted the code
got this:
Day0
protein,5.3
vitamins,6.3
Carbonhydrate,7.3
Day1
protein,5.3
vitamins,6.3
Carbonhydrate,7.3
Day2
protein,5.3
vitamins,6.3
Carbonhydrate,7.3
Day3
protein,5.3
vitamins,6.3
Carbonhydrate,7.3
----------------------------------------
But I want this:
Day0
protein,2.0
vitamins,3.0
Carbonhydrate,4.0
Day1
protein,3.1
vitamins,4.1
Carbonhydrate,5.1
Day2
protein,4.2
vitamins,5.2
Carbonhydrate,6.2
Day3
protein,5.3
vitamins,6.3
Carbonhydrate,7.3
-----------------
I still want to have access to the values of the previous days not just the last day.
this is my output code
----------------------------
using (StreamWriter sw = new StreamWriter(@"U:\Food\food.txt"))
{
sw.WriteLine("Day" + "{0}", 0);
for (int ii = 0; ii < types; ii++)
{
sw.WriteLine("{0},{1}", food[ii].Type, food[ii].Calories);
}
sw.WriteLine("");
for (int i = 0; i < days; i++)
{
{
sw.WriteLine("Day" + "{0}", i + 1);
for (int ii = 0; ii < types; ii++)
{
sw.WriteLine("{0},{1}", food[ii].Type, food[ii].Calories);
}
sw.WriteLine("");
}
}
}