#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;
class DietaryGuideline
{
public:
DietaryGuideline() {}
DietaryGuideline(unsigned int calories) : grains(0), protein(0), dairy(0), vegetables(0), fruits(0), fatsNnuts(0)
{
if (calories <= 1500)
{
rda_grains = 2.5;
rda_protein = 4;
rda_dairy = 1.5;
rda_vegetables = 3;
rda_fruits = 2;
rda_fatsNnuts = 4;
}
else if (calories <= 2000)
{
rda_grains = 3;
rda_protein = 6;
rda_dairy = 1.5;
rda_vegetables = 4;
rda_fruits = 3;
rda_fatsNnuts = 6;
}
else
{
rda_grains = 4;
rda_protein = 7;
rda_dairy = 1.5;
rda_vegetables = 5;
rda_fruits = 4;
rda_fatsNnuts = 7;
}
}
protected:
double grains, protein, dairy, vegetables, fruits, fatsNnuts;
void info()
{
string health_stauts = "UNSET";
string grains_status, protein_status, dairy_status, vegetables_status, fruits_status, fatsNnuts_status;
grains_status = protein_status = dairy_status = vegetables_status = fruits_status = fatsNnuts_status = "UNSET";
// Note: riskAnalysis() is only call here. Please understand the intension.
risksAnalysis(&grains_status, &protein_status, &dairy_status, &vegetables_status, &fruits_status, &fatsNnuts_status, &health_stauts);
cout << "[Health Report]" << endl;
cout << "health ststus: " << health_stauts << endl;
cout << right << setw(16) << setfill(' ') << "" << setw(8) << "status"
<< " | " << setw(7) << "intake"
<< " | " << setw(4) << "RDA"
<< " | " << setw(4) << "MAR"
<< endl;
cout << right << setw(16) << setfill(' ') << "grains: " << setw(8) << grains_status
<< " " << setw(7) << grains << " " << setw(4) << rda_grains << " " << setw(4) << MAR << endl;
cout << right << setw(16) << setfill(' ') << "protein: " << setw(8) << protein_status
<< " " << setw(7) << protein << " " << setw(4) << rda_protein << " " << setw(4) << MAR << endl;
cout << right << setw(16) << setfill(' ') << "dairy: " << setw(8) << dairy_status
<< " " << setw(7) << dairy << " " << setw(4) << rda_dairy << " " << setw(4) << MAR << endl;
cout << right << setw(16) << setfill(' ') << "vegetables: " << setw(8) << vegetables_status
<< " " << setw(7) << vegetables << " " << setw(4) << rda_vegetables << " " << setw(4) << MAR << endl;
cout << right << setw(16) << setfill(' ') << "fruits: " << setw(8) << fruits_status
<< " " << setw(7) << fruits << " " << setw(4) << rda_fruits << " " << setw(4) << MAR << endl;
cout << right << setw(16) << setfill(' ') << "fats and nuts: " << setw(8) << fatsNnuts_status
<< " " << setw(7) << fatsNnuts << " " << setw(4) << rda_fatsNnuts << " " << setw(4) << MAR << endl;
}
private:
// RDA = Recommended Dietary Allowance
// MAR = Maximum Allowable Range
double rda_grains, rda_protein, rda_dairy, rda_vegetables, rda_fruits, rda_fatsNnuts;
double MAR = 0.5;
void risksAnalysis(string *g_status, string *p_status, string *d_status, string *v_status, string *fr_status, string *fa_status, string *h_status)
{
/* Todo */
/* Example
if (abs(rda_grains - grains) > MAR)
*g_status = "warning";
...
*/
}
};
class Breakfast /* Todo */
{
protected:
Breakfast() : grains(0), protein(0), dairy(0), vegetables(0), fruits(0), fatsNnuts(0) {}
void eat(double g, double p, double d, double v, double fr, double fa)
{
// for Breakfast information
/* Todo */
// for DG information
/* Todo */
}
void info()
{
cout << "[Breakfast]" << endl;
cout << right << setw(9) << setfill(' ') << "" << setw(8) << "grains"
<< " | " << setw(9) << "protein"
<< " | " << setw(7) << "dairy"
<< " | " << setw(12) << "vegetables"
<< " | " << setw(8) << "fruits"
<< " | " << setw(15) << "fats and nuts"
<< endl;
cout << right << setw(9) << setfill(' ') << "intake:" << setw(8) << grains
<< " " << setw(9) << protein
<< " " << setw(7) << dairy
<< " " << setw(12) << vegetables
<< " " << setw(8) << fruits
<< " " << setw(15) << fatsNnuts
<< endl;
}
private:
double grains, protein, dairy, vegetables, fruits, fatsNnuts;
};
class Lunch /* Todo */
{
protected:
Lunch() : grains(0), protein(0), dairy(0), vegetables(0), fruits(0), fatsNnuts(0) {}
void eat(double g, double p, double d, double v, double fr, double fa)
{
// for Lunch information
/* Todo */
// for DG information
/* Todo */
}
void info()
{
cout << "[Lunch]" << endl;
cout << right << setw(9) << setfill(' ') << "" << setw(8) << "grains"
<< " | " << setw(9) << "protein"
<< " | " << setw(7) << "dairy"
<< " | " << setw(12) << "vegetables"
<< " | " << setw(8) << "fruits"
<< " | " << setw(15) << "fats and nuts"
<< endl;
cout << right << setw(9) << setfill(' ') << "intake:" << setw(8) << grains
<< " " << setw(9) << protein
<< " " << setw(7) << dairy
<< " " << setw(12) << vegetables
<< " " << setw(8) << fruits
<< " " << setw(15) << fatsNnuts
<< endl;
}
private:
double grains, protein, dairy, vegetables, fruits, fatsNnuts;
};
class Dinner /* Todo */
{
protected:
Dinner() : grains(0), protein(0), dairy(0), vegetables(0), fruits(0), fatsNnuts(0) {}
void eat(double g, double p, double d, double v, double fr, double fa)
{
// for Dinner information
/* Todo */
// for DG information
/* Todo */
}
void info()
{
cout << "[Dinner]" << endl;
cout << right << setw(9) << setfill(' ') << "" << setw(8) << "grains"
<< " | " << setw(9) << "protein"
<< " | " << setw(7) << "dairy"
<< " | " << setw(12) << "vegetables"
<< " | " << setw(8) << "fruits"
<< " | " << setw(15) << "fats and nuts"
<< endl;
cout << right << setw(9) << setfill(' ') << "intake:" << setw(8) << grains
<< " " << setw(9) << protein
<< " " << setw(7) << dairy
<< " " << setw(12) << vegetables
<< " " << setw(8) << fruits
<< " " << setw(15) << fatsNnuts
<< endl;
}
private:
double grains, protein, dairy, vegetables, fruits, fatsNnuts;
};
class Human : public Breakfast, Lunch, Dinner
{
public:
Human(unsigned int calories) : Breakfast(), Lunch(), Dinner(), DietaryGuideline(calories) {}
void eatBreakfast(double g, double p, double d, double v, double fr, double fa)
{
/* Todo */
}
void eatLunch(double g, double p, double d, double v, double fr, double fa)
{
/* Todo */
}
void eatDinner(double g, double p, double d, double v, double fr, double fa)
{
/* Todo */
}
void healthReport()
{
DietaryGuideline::info();
cout << endl;
Breakfast::info();
cout << endl;
Lunch::info();
cout << endl;
Dinner::info();
}
};
void check()
{
int testcase;
cin >> testcase;
if (testcase == 1)
{
Human human = Human(1300);
human.eatBreakfast(1, 1, 1, 1, 1, 1);
human.eatLunch(1, 1, 1, 1, 1, 1);
human.eatDinner(1, 1, 1, 1, 1, 1);
human.healthReport();
}
else if (testcase == 2)
{
Human human = Human(1500);
human.eatBreakfast(1, 1, 1, 1, 1, 1);
human.eatLunch(1, 2, 0, 1.5, 1, 1.5);
human.eatDinner(1, 1, 0, 1, 0.5, 1);
human.healthReport();
}
else if (testcase == 3)
{
Human human = Human(1700);
human.eatBreakfast(0.4, 3, 2, 1, 0, 1);
human.eatLunch(1, 2, 0, 1, 1, 1);
human.eatDinner(1, 2, 0.1, 1.5, 1, 1);
human.healthReport();
}
else if (testcase == 4)
{
Human human = Human(2000);
human.eatBreakfast(0, 3, 0.5, 2, 1, 1);
human.eatLunch(1, 1, 0, 1.3, 1, 3);
human.eatDinner(1, 1.5, 1, 0.1, 1, 3);
human.healthReport();
}
else if (testcase == 5)
{
Human human = Human(2400);
human.eatBreakfast(1, 1, 1, 1, 1, 1);
human.eatLunch(1, 1, 1, 1, 1, 1);
human.eatDinner(1, 1, 1, 1, 1, 1);
human.healthReport();
}
}
int main()
{
check();
return 0;
}
No need to handle input. (Input would be number 1~5 to represent the index of test-case)