diff --git a/inventory_management_system.cpp b/inventory_management_system.cpp index caacdfff93a8cb404909d32fd0d0edca9e81794e..ff3c0445676037bb4f206bf00aa534cf0641d92f 100644 --- a/inventory_management_system.cpp +++ b/inventory_management_system.cpp @@ -179,32 +179,80 @@ public: cout << "----------------" << endl; } } + // nbagga UI Menu + // Display a menu to interact with the inventory + void displayMenu() { + while (true) { + cout << "=== Inventory Management ===" << endl; + cout << "1. Add Toy" << endl; + cout << "2. Delete Toy" << endl; + cout << "3. Update Toy" << endl; + cout << "4. Display Inventory" << endl; + cout << "5. Exit" << endl; + cout << "Enter your choice: "; + + int choice; + cin >> choice; + + switch (choice) { + case 1: { + Toy newToy = inputToyDetails(); + addToy(newToy); + break; + } + case 2: { + string name; + cout << "Enter the name of the toy to delete: "; + cin.ignore(); + getline(cin, name); + deleteToy(name); + break; + } + case 3: { + string name; + cout << "Enter the name of the toy to update: "; + cin.ignore(); + getline(cin, name); + Toy updatedToy = inputToyDetails(); + updateToy(name, updatedToy); + break; + } + case 4: + displayInventory(); + break; + case 5: + return; + default: + cout << "Invalid choice. Please try again." << endl; + } + } + } + + Toy inputToyDetails() { + string name, material, description; + double manufacturingPrice; + int quantityInStock; + + cout << "Enter Toy Name: "; + cin.ignore(); + getline(cin, name); + cout << "Enter Material: "; + getline(cin, material); + cout << "Enter Description: "; + getline(cin, description); + cout << "Enter Manufacturing Price: $"; + cin >> manufacturingPrice; + cout << "Enter Quantity in Stock: "; + cin >> quantityInStock; + + Toy newToy(name, material, description, manufacturingPrice, quantityInStock); + return newToy; + } }; int main() { Inventory inventory; - - // Adding sample toys to the inventory - Toy toy1("Toy1", "Plastic", "A fun toy", 5.99, 50); - Toy toy2("Toy2", "Wood", "Educational toy", 9.99, 30); - inventory.addToy(toy1); - inventory.addToy(toy2); - - // Display the initial inventory - inventory.displayInventory(); - - // Update a toy - Toy updatedToy("Toy1", "Metal", "An upgraded version of Toy1", 7.99, 60); - inventory.updateToy("Toy1", updatedToy); - - // Display the updated inventory - inventory.displayInventory(); - - // Delete a toy - inventory.deleteToy("Toy2"); - - // Display the updated inventory after deletion - inventory.displayInventory(); + inventory.displayMenu(); return 0; -} +} \ No newline at end of file