Page 1 of 1

CHANGE the following in the code provided below. #include #include using namespace std; class Meal {

Posted: Tue Jul 05, 2022 10:26 am
by answerhappygod
CHANGE the following in the code provided below.
#include <iostream>#include <string>using namespace std;
class Meal{public:Meal(string n, string t){name = n;time = t;}void setName(string n){name = n;}string getName(){return name;}void setTime(string t){time = t;}string getTime(){return time;}private:string name;string time;};
class User{public:User(string n){name = n;}void setName(string n){name = n;}string getName(){return name;}private:string name;};
class Week{public:Week(){for(int i = 0; i < 21; i++){meals = NULL;}}void setMeal(Meal* m, int day, int meal){meals[(day - 1) * 3 + meal - 1] = m;}Meal* getMeal(int day, int meal){return meals[(day - 1) * 3 + meal - 1];}private:Meal* meals[21];};
int main(){User* user = new User("Bob");Week* week = new Week();Meal* meal1 = new Meal("Pizza", "Dinner");Meal* meal2 = new Meal("Hamburger", "Lunch");Meal* meal3 = new Meal("Cereal", "Breakfast");week->setMeal(meal1, 1, 3);week->setMeal(meal2, 2, 2);week->setMeal(meal3, 3, 1);for(int i = 1; i <= 3; i++){for(int j = 1; j <= 3; j++){Meal* meal = week->getMeal(i, j);if(meal != NULL){cout << user->getName() << "'s " <<meal->getTime() << " meal on day " << i << "is " << meal->getName() << endl;}}}return 0;}
1.) CREATE an interactive user interface for selecting a meal(Must include 10 meals)
2.) Be able to select a meal and assign it to a day of the weekand to a time of day (Breakfast, Lunch or Dinner)
3.) Print the ENTIRE 21 meals for the week and include thepersons name (as an input)