This is for a C++ class, and I'm supposed to figure out what the problem is with
Question:
This is for a C++ class, and I'm supposed to figure out what the problem is with this "Dairy" resource file. I can tell its something with the pop and pushback and adding something to the vector of the menu, but I can't grasp why its wrong. The first image is the code for the "Dairy" resource file, the second is the header file for said resource file, and I have pasted the code for the full program that "Dairy" is a part of, it has to do with building a menu of food, I think.
=============
#include
#include "Dairy.h"
#include "Fruit.h"
#include "Meat.h"
#include "Veggies.h"
using namespace std;
int main()
{
int option = 0;
int food = 0;
string name;
while (option != 3)
{
cout << "Please select option for Zoo Maintenance" << endl;
cout << "1. Add Food to a Food Group." << endl;
cout << "2. List count of each food in the Food Groups." << endl;
cout << "3. Quit." << endl;
cout << "Select option: ";
cin >> option;
if (option == 1)
{
while (food != 5)
{
cout << "Please select food type to add to Food Group." << endl;
cout << "1. Dairy" << endl;
cout << "2. Fruit" << endl;
cout << "3. Meat" << endl;
cout << "4. Veggies" << endl;
cout << "5. Exit food Entry" << endl;
cout << "Select Option: ";
cin >> food;
if (food == 1)
{
cout << "Give your Dairy a name: ";
cin >> name;
Dairy dairy(name);
}
else if (food == 2)
{
cout << "Give your Fruit a name: ";
cin >> name;
Fruit fruit(name);
}
else if (food == 3)
{
cout << "Give your Meat a name: ";
cin >> name;
Meat meat(name);
}
else if (food == 4)
{
cout << "Give your Veggies a name: ";
cin >> name;
Veggies veg(name);
}
else if (food == 5)
break;
else
cout << "Invalid Option!!" << endl;
}
}
else if (option == 2)
{
cout << "There are " << Dairy::Dairy_Total << " Dairy(s) in the Food Group." << endl;
cout << "List of Dairy Food:" << endl;
Dairy stuff("temp");
stuff.listFood();
cout << "There are " << Fruit::Fruit_Total << " Fruit(s) in the Food Group." << endl;
cout << "There are " << Meat::Meat_Total << " Meat(s) in the Food Group." << endl;
cout << "There are " << Veggies::Veggies_Total << " Veggie(s) in the Food Group." << endl;
}
else if (option == 3)
{
cout << "Goodbye." << endl;
break;
}
else
cout << "Invalid Option!!" << endl;
food = 0;
}
system("pause");
return 0;
}
======================================================