Guest User

Untitled

a guest
May 15th, 2018
685
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.38 KB | None | 0 0
  1. /***********************************************************************
  2.  * createMenu.cpp
  3.  * -
  4.  * -
  5.  * -
  6.  **********************************************************************/
  7.  
  8. #include <iostream>
  9.  
  10. #include "createMenu.h"
  11.  
  12. using std::cout;
  13. using std::cin;
  14. using std::endl;
  15.  
  16. // Create vector to hold menuItems
  17. Menu::Menu() {}
  18.  
  19. int main() {
  20.  
  21. int selection;
  22.     while (1) {
  23.         cout << "Welcome to the menu manager." << endl << endl;
  24.        
  25.         cout << "Please select an option:" << endl << endl;
  26.         cout << "(1) Display current menu items" << endl;
  27.         cout << "(2) Add a menu item" << endl;
  28.         cout << "(3) Delete a menu item" << endl;
  29.         cout << "(4) Exit" << endl << endl;
  30.        
  31.         cout << "Selection: ";
  32.         cin >> selection;
  33.        
  34.         switch (selection) {
  35.             case 1:
  36.                 cout << "Dummy option 1";
  37.                 break;
  38.            
  39.             case 2:
  40.                 Menu::addItem();
  41.                 break;
  42.                
  43.             case 3:
  44.                 cout << "Dummy option 2";
  45.                 break;
  46.                
  47.             case 4:
  48.                 cout << endl << "Exiting program.";
  49.                 return 0;
  50.                
  51.             default:
  52.                 cout << endl << "[ERROR] ";
  53.                 cout << "Please enter a valid selection between 1-4.";
  54.                 cout << endl << endl;
  55.         }
  56.     }
  57.     return 0;
  58. }
  59.  
  60. // Method to add new menu item to items vector.
  61. // USE THIS TO ADD ITEMS!!!
  62. void Menu::addItem() {
  63.     char cat;
  64.     string desc;
  65.     float price;
  66.    
  67.     // Get category
  68.     cout << endl;
  69.     cout << "Adding a new menu item:" << endl << endl;
  70.     cout << "Enter a category:" << endl;
  71.     cout << "(m) Meat dishes" << endl;
  72.     cout << "(f) Fish dishes" << endl;
  73.     cout << "(v) Vegetarian dishes" << endl;
  74.     cout << "(d) Drinks" << endl << endl;
  75.     cout << "Entry: ";
  76.     // Write to local var
  77.     cin >> cat;
  78.     cin.ignore(); // Clear \n from cin buffer
  79.    
  80.     // Get description
  81.     cout << endl;
  82.     cout << "Enter a description:" << endl;
  83.     cout << "Entry: ";
  84.     // Write to local var
  85.     getline(cin, desc);
  86.    
  87.     // Get price
  88.     cout << endl << endl;
  89.     cout << "Enter a price:" << endl;
  90.     cout << "Entry: ";
  91.     // Write to local var
  92.     cin >> price;
  93.    
  94.     _items.push_back(MenuItem(cat, desc, price));
  95. }
  96.  
  97. // Set MenuItem properties from parameters on obj creation
  98. MenuItem::MenuItem(char category, string desc, float price) :
  99.     _category(category), _description(desc), _price(price) { }
  100.  
  101.  
  102.  
  103. /*
  104. void MenuItem::displayPerson() {
  105.     cout << "Category: " << _category << endl;
  106.     cout << "Description: " << _description << endl;
  107.     cout << "Price: " << _price << endl;
  108. }
  109.  
  110. */
Advertisement
Add Comment
Please, Sign In to add comment