Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***********************************************************************
- * createMenu.cpp
- * -
- * -
- * -
- **********************************************************************/
- #include <iostream>
- #include "createMenu.h"
- using std::cout;
- using std::cin;
- using std::endl;
- // Create vector to hold menuItems
- Menu::Menu() {}
- int main() {
- int selection;
- while (1) {
- cout << "Welcome to the menu manager." << endl << endl;
- cout << "Please select an option:" << endl << endl;
- cout << "(1) Display current menu items" << endl;
- cout << "(2) Add a menu item" << endl;
- cout << "(3) Delete a menu item" << endl;
- cout << "(4) Exit" << endl << endl;
- cout << "Selection: ";
- cin >> selection;
- switch (selection) {
- case 1:
- cout << "Dummy option 1";
- break;
- case 2:
- Menu::addItem();
- break;
- case 3:
- cout << "Dummy option 2";
- break;
- case 4:
- cout << endl << "Exiting program.";
- return 0;
- default:
- cout << endl << "[ERROR] ";
- cout << "Please enter a valid selection between 1-4.";
- cout << endl << endl;
- }
- }
- return 0;
- }
- // Method to add new menu item to items vector.
- // USE THIS TO ADD ITEMS!!!
- void Menu::addItem() {
- char cat;
- string desc;
- float price;
- // Get category
- cout << endl;
- cout << "Adding a new menu item:" << endl << endl;
- cout << "Enter a category:" << endl;
- cout << "(m) Meat dishes" << endl;
- cout << "(f) Fish dishes" << endl;
- cout << "(v) Vegetarian dishes" << endl;
- cout << "(d) Drinks" << endl << endl;
- cout << "Entry: ";
- // Write to local var
- cin >> cat;
- cin.ignore(); // Clear \n from cin buffer
- // Get description
- cout << endl;
- cout << "Enter a description:" << endl;
- cout << "Entry: ";
- // Write to local var
- getline(cin, desc);
- // Get price
- cout << endl << endl;
- cout << "Enter a price:" << endl;
- cout << "Entry: ";
- // Write to local var
- cin >> price;
- _items.push_back(MenuItem(cat, desc, price));
- }
- // Set MenuItem properties from parameters on obj creation
- MenuItem::MenuItem(char category, string desc, float price) :
- _category(category), _description(desc), _price(price) { }
- /*
- void MenuItem::displayPerson() {
- cout << "Category: " << _category << endl;
- cout << "Description: " << _description << endl;
- cout << "Price: " << _price << endl;
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment