Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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;
}

======================================================
 

1 4234 5 6 7 8 000 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 #include #include "Dairy.h" using namespace std; int Dairy::Dairy_Total = 0; Dairy::~Dairy() { cout < < " It is destroyed:" < < endl; Dairy::Dairy(string nam) { name = nam; cout < < " Welcome < < name < < a new Dairy to the Menu!!" < < endl; ++Dairy_ Total; vec.push_back(name); Evoid Dairy::listFood () { vector ::iterator iter; vec.pop_back(); --Dairy_Total; for (iter = vec.begin(); iter != vec.end(); ++iter) cout < < *iter < < endl;

Step by Step Solution

3.25 Rating (114 Votes )

There are 3 Steps involved in it

Step: 1

include include Dairyh include Fruith include Meath include Veggiesh using namespace std int main int option 0 int food 0 string name while option 3 c... blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial Markets and Institutions

Authors: Jeff Madura

12th edition

9781337515535, 1337099740, 1337515531, 978-1337099745

More Books

Students also viewed these Mechanical Engineering questions