Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main()
- {
- std::map<std::string, Customer> customersMap;
- std::set<Item> itemList = {
- Item("Milk","00001",5.3),
- Item("Cookies","00002",12.6),
- Item("bread","00003",8.9),
- Item("chocolate","00004",7.0),
- Item("cheese","00005",15.3),
- Item("rice","00006",6.2),
- Item("fish", "00008", 31.65),
- Item("chicken","00007",25.99),
- Item("cucumber","00009",1.21),
- Item("tomato","00010",2.32) };
- std::set<Item>* test = new std::set<Item>();
- int userMenuChoice = 0;
- printMenu();
- std::cout << "Enter your choice: ";
- std::cin >> userMenuChoice;
- while(EXIT_MENU_OPTION != userMenuChoice)
- {
- if(SIGN_AS_CUSTOMER_AND_BUY_ITEMS_MENU_OPTION == userMenuChoice)
- {
- std::string customerName;
- std::cout << "Enter your name: ";
- std::cin >> customerName;
- std::map<std::string, Customer>::iterator customerIterator = customersMap.find(customerName);
- if (customerIterator == customersMap.end())
- {
- customersMap[customerName] = Customer();
- //customersMap.insert(std::pair<std::string, Customer>(customerName, Customer(customerName)));
- addItems(customersMap[customerName], itemList);
- }
- else
- {
- std::cout << "A user with that name already exists!" << std::endl;
- }
- }
- else if(UPDATE_EXISTING_CUSTOMERS_ITEMS_MENU_OPTION == userMenuChoice)
- {
- std::string customerName;
- std::cout << "Enter your name: ";
- std::cin >> customerName;
- std::map<std::string, Customer>::iterator customerIterator = customersMap.find(customerName);
- if (customerIterator != customersMap.end())
- {
- std::cout << "1. Add items" << std::endl
- << "2. Remove items" << std::endl
- << "3. Back to menu" << std::endl;
- int userChoice = 0;
- std::cout << "Enter your choice: ";
- std::cin >> userChoice;
- if(1 == userChoice)
- {
- addItems(customerIterator->second, itemList);
- }
- else if(2 == userChoice)
- {
- removeItem(customerIterator->second);
- }
- }
- }
- printMenu();
- std::cout << "Enter your choice: ";
- std::cin >> userMenuChoice;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement