The program starts with showing output:
"1. Add item 2. View items 3. Search item using Product ID 4. Search item using Product Name 5. Delete item 6. Exit"
and asks user to type any of these numbers to do an operation.
If user inputs anything else except 1-6, this will show "Invalid input, please try again."
We will take a class named InventoryItem then take int type of variable for serial number, quantity and price and string Name and double for product ID.
We will have a constructor as well so that we can create objects to push into the vector named InventoryItems.
The addItem function starts by showing output "Enter Product serial, productID, quantity & price" and takes input of those. After taking input, it creates a object with the help of the constructor and after finishing the operation, shows output "Product added successfully"
viewItem function iterates through the vector using a for loop and then shows output as following:
Serial:
Name:
Product ID:
Quantity:
Price:
Incase, if the vector is empty, it will show output "No items to display"
SearchItemUsingProductID function asks for the ID of the product and when user inputs the ID, it iterates through the vector using a for loop and locates the product then shows output as following:
Serial:
Name:
Product ID:
Quantity:
Price:
Incase, if it can't find the product with same ID, it will show output "Product Not Found!"
SearchItemUsingProductName function asks for the name of the product and when user inputs the name, it iterates through the vector using a for loop and locates the product then shows output as following:
Serial:
Name:
Product ID:
Quantity:
Price:
Incase, if it can't find the product with same name, it will show output "Product Not Found!"
The deleteItem function asks for a name to input to delete that item from the vector. It takes the name input as a string.
Afterwards, we will use an iterator to iterate through the vector to find the desired item if we can find the item, we will erase the item details.
If the item couldn't be found, it will show output "Product Not Found!"