Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include "ShoppingCart.h"
- using namespace std;
- char PrintMenu() {
- char option;
- cout << endl;
- cout << " --MENU--" << endl;
- cout << "a - Add item to cart" << endl;
- cout << "d - Remove item from cart" << endl;
- cout << "c - Change item quantity" << endl;
- cout << "i - Output items' descriptions" << endl;
- cout << "o - Output shopping cart" << endl;
- cout << "q - Quit" << endl;
- cout << "Choose an option:";
- cin >> option;
- cout << endl;
- return option;
- }
- ItemToPurchase AddItem() {
- string itemName;
- string itemDescription;
- int itemQuantity;
- int itemPrice;
- cout << "ADD ITEM TO CART" << endl;
- cout << "Enter the item name: " << endl;
- getline(cin, itemName);
- cin.ignore();
- cout << "Enter the item description: " << endl;
- getline(cin, itemDescription);
- cin.ignore();
- cout << "Enter the item price: " << endl;
- cin >> itemPrice;
- cout << "Enter the item quantity: " << endl;
- cin >> itemQuantity;
- ItemToPurchase item(itemName, itemPrice, itemQuantity, itemDescription);
- return item;
- }
- int main()
- {
- char userInput;
- //ItemToPurchase item;
- string customerName;
- string currentDate;
- string itemName = "none";
- string itemDescription;
- int itemQuantity;
- string removeItem;
- cout << "Enter Customer's Name: " << endl;
- getline(cin, customerName);
- cout << "Enter Today's Date: " << endl;
- getline(cin, currentDate);
- cout << "Customer Name: " << customerName << endl;
- cout << "Today's Date: " << currentDate << endl << endl;
- ShoppingCart cartItems(customerName, currentDate);
- userInput = PrintMenu();
- while (userInput != 'q')
- {
- if (userInput == 'a')
- {
- cartItems.AddItem(AddItem());
- }
- else if (userInput == 'd')
- {
- cout << "REMOVE ITEM FROM CART" << endl;
- cout << "Enter name of item to remove:" << endl;
- cin.ignore();
- getline(cin, removeItem);
- ShoppingCart RemoveItem(string removeItem);
- }
- else if (userInput == 'c')
- {
- cout << "CHANGE ITEM QUANTITY" << endl;
- cout << "Enter the item name:" << endl;
- getline(cin, itemName);
- //item.GetQuantity();
- cout << "Enter the new quantity:" << endl;
- cin >> itemQuantity;
- //cartItems.ModifyItem(item);
- }
- else if (userInput == 'i')
- {
- cout << "OUTPUT ITEMS' DESCRIPTIONS" << endl;
- ShoppingCart PrintDescriptions();
- }
- else if (userInput == 'o')
- {
- // FIX
- cout << "OUTPUT SHOPPING CART" << endl;
- cartItems.PrintTotal();
- }
- else if (userInput == 'q')
- {
- break;
- }
- userInput = PrintMenu();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement