-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalorieCalculator.cs
63 lines (58 loc) · 1.6 KB
/
CalorieCalculator.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WellBites.Models;
namespace WellBites
{
/*
* Mifflin-St Jeor Equation:
For men:
BMR = 10W + 6.25H - 5A + 5
For women:
BMR = 10W + 6.25H - 5A - 161
where:
W is body weight in kg
H is body height in cm
A is age
F is body fat in percentage
*
*/
/*
*
If you are sedentary (little or no exercise) : Calorie-Calculation = BMR x 1.2
If you are lightly active (light exercise/sports 1-3 days/week) : Calorie-Calculation = BMR x 1.375
If you are moderatetely active (moderate exercise/sports 3-5 days/week) : Calorie-Calculation = BMR x 1.55
If you are very active (hard exercise/sports 6-7 days a week) : Calorie-Calculation = BMR x 1.725
If you are extra active (very hard exercise/sports & physical job or 2x training) : Calorie-Calculation = BMR x 1.9
*/
internal class CalorieCalculator
{
public double GetActivityMultiplier(Activity activity)
{
switch(activity)
{
case Activity.Sedentary:
return 1.2;
case Activity.Light:
return 1.375;
case Activity.Moderate:
return 1.55;
case Activity.VeryActive:
return 1.725;
case Activity.ExtraActive:
return 1.9;
default: //bmr
return 1;
}
}
public int GetCaloriesPerDay(User user, Activity activity)
{
int sex_variable = user.Sex == Sex.Male ? 5 : -161;
TimeSpan timeDifference = DateTime.Now - user.DateOfBirth;
double bmr = 10 * user.Weight + 6.25 * user.Height - 5 * user.Age + sex_variable;
return (int)Math.Round(GetActivityMultiplier(activity) * bmr);
}
}
}