Make sure that the
Calories
class gets
newUser
, for example as argument to
CalculateCaloriesMale
:
public void CalcuateCaloriesMale(User user)
{
var equation = (10 * user.Weight) + (6.25 * user.Height) - (5 * user.Age) + 5;
Console.WriteLine("Based on the Mifflin – St Jeor Formula You need to eat {0} Kalories a day\nTo Gain Weight ", equation);
}
...
if (newGoal.GoalStatusGainWeight == true)
{
var calories = new Calories();
switch (newUser.Gender)
{
case "m":
calories.CalcuateCaloriesMale(newUser);
break;
Alternatively, you could create a
constructor[
^] for
Calories
and take a
User
there and store it, then use it in a parameterless
CalculateCaloriesMale
class.
Side note: it hardly makes sense to make
Calories
inherit from
User
. It would appear to a human developer as if Calories is a certain type of User, which is of course not true. And it doesn't look like it has any use.