Page 1 of 1

Expand on the following C++ code to achieve the following. Make an interactive user interface (ie giving in a number to

Posted: Tue Jul 05, 2022 10:25 am
by answerhappygod
Expand on the following C++ code to achieve the following. Makean interactive user interface (ie giving in a number to make aselection) To allow the user to choose their meal and then selectwhat day and when they would like to eat the meal (breakfast,lunch, and, dinner) Have the user input their name. Have the userbe able to view ALL 21 meals for the week including breakfast,lunch, and, dinner for each day. Have 10 available meals to beselected. Use a linked list to have all of the meals storedfor the user to pick from. Implement a Queue for the 21 meals eachweek. Be able to add and remove and change meal plans for eachday.
#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;}