/********************************************************************* C201 Computer Programming II Fall 2006 Dana Vrajitoru & A class to represent the inventory of a shop. **********************************************************************/ #include "inventory.h" #include using namespace std; // Prototypes for functions defined here. void Print_menu(); void Execute_menu(char option, Inventory &shop); int main() { Inventory shop; // An example of opening a file with an absolute path: // shop.Input_file("O:/C201/Programs/h8_sol/data8.txt"); // The following is a relative file name. The program will look for // it in the current directory. shop.Input_file("data8.txt"); char option = '\0'; while (option != 'q' && option != 'Q') { Print_menu(); cin >> option; Execute_menu(option, shop); } return 0; } void Print_menu() { cout << "Choose an action from the following:" << endl << "[A] Add a new item to the stock" << endl << "[I] Increase the quantity of an existing item" << endl << "[S] Sell aq uantity of an existing item" << endl << "[P] Print the entire stock" << endl << "[Q] quit" << endl; } void Execute_menu(char option, Inventory &shop) { switch (option) { case 'q': case 'Q': cout << "Goodbye." << endl; break; case 'a': case 'A': shop.Add_new(); break; case 'i': case 'I': shop.Add_by_name(); break; case 's': case 'S': shop.Sell_by_name(); break; case 'p': case 'P': shop.Output_all(); break; } }