SHARE
TWEET

Untitled

a guest Mar 21st, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3. #include "ShoppingCart.h"
  4.  
  5. using namespace std;
  6.  
  7. char PrintMenu() {
  8.    char option;
  9.    cout << endl;
  10.     cout << "       --MENU--" << endl;
  11.     cout << "a - Add item to cart" << endl;
  12.     cout << "d - Remove item from cart" << endl;
  13.     cout << "c - Change item quantity" << endl;
  14.     cout << "i - Output items' descriptions" << endl;
  15.     cout << "o - Output shopping cart" << endl;
  16.     cout << "q - Quit" << endl;
  17.  
  18.     cout << "Choose an option:";
  19.    
  20.     cin >> option;
  21.  
  22.     cout << endl;
  23.    
  24.     return option;
  25. }
  26.  
  27. ItemToPurchase AddItem() {
  28.    string itemName;
  29.    string itemDescription;
  30.    int itemQuantity;
  31.    int itemPrice;
  32.    
  33.    cout << "ADD ITEM TO CART" << endl;
  34.     cout << "Enter the item name: " << endl;
  35.     getline(cin, itemName);
  36.     cin.ignore();
  37.  
  38.     cout << "Enter the item description: " << endl;
  39.     getline(cin, itemDescription);
  40.     cin.ignore();
  41.  
  42.     cout << "Enter the item price: " << endl;
  43.     cin >> itemPrice;
  44.  
  45.     cout << "Enter the item quantity: " << endl;
  46.     cin >> itemQuantity;
  47.  
  48.    ItemToPurchase item(itemName, itemPrice, itemQuantity, itemDescription);
  49.    
  50.    return item;
  51. }
  52.  
  53. int main()
  54. {
  55.     char userInput;
  56.     //ItemToPurchase item;
  57.  
  58.     string customerName;
  59.     string currentDate;
  60.     string itemName = "none";
  61.     string itemDescription;
  62.     int itemQuantity;
  63.     string removeItem;
  64.  
  65.     cout << "Enter Customer's Name: " << endl;
  66.     getline(cin, customerName);
  67.  
  68.     cout << "Enter Today's Date: " << endl;
  69.     getline(cin, currentDate);
  70.  
  71.     cout << "Customer Name: " << customerName << endl;
  72.  
  73.     cout << "Today's Date: " << currentDate << endl << endl;
  74.  
  75.     ShoppingCart cartItems(customerName, currentDate);
  76.    
  77.    userInput = PrintMenu();
  78.  
  79.     while (userInput != 'q')
  80.     {      
  81.         if (userInput == 'a')
  82.         {
  83.            cartItems.AddItem(AddItem());
  84.         }
  85.  
  86.         else if (userInput == 'd')
  87.         {
  88.             cout << "REMOVE ITEM FROM CART" << endl;
  89.             cout << "Enter name of item to remove:" << endl;
  90.  
  91.             cin.ignore();
  92.  
  93.             getline(cin, removeItem);
  94.  
  95.             ShoppingCart RemoveItem(string removeItem);
  96.         }
  97.  
  98.         else if (userInput == 'c')
  99.         {
  100.             cout << "CHANGE ITEM QUANTITY" << endl;
  101.             cout << "Enter the item name:" << endl;
  102.             getline(cin, itemName);
  103.          
  104.          //item.GetQuantity();
  105.          
  106.             cout << "Enter the new quantity:" << endl;
  107.             cin >> itemQuantity;
  108.            
  109.             //cartItems.ModifyItem(item);
  110.         }
  111.  
  112.         else if (userInput == 'i')
  113.         {
  114.             cout << "OUTPUT ITEMS' DESCRIPTIONS" << endl;
  115.  
  116.             ShoppingCart PrintDescriptions();
  117.         }
  118.  
  119.         else if (userInput == 'o')
  120.         {
  121.            // FIX
  122.            
  123.             cout << "OUTPUT SHOPPING CART" << endl;
  124.          
  125.             cartItems.PrintTotal();
  126.         }
  127.        
  128.         else if (userInput == 'q')
  129.         {
  130.            break;
  131.         }
  132.        
  133.         userInput = PrintMenu();
  134.     }
  135.    
  136.     return 0;
  137. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top