A shop inventory manager
The problem
Build a program that tracks a shop's products, stock levels and sales, and produces reports.
Requirements
- A Money class stores amounts in whole paisa and supports +, -, * by a count, comparison and printing
- A Product class keeps a name, a price and a stock level, and refuses to sell more than it has
- Products are stored in a map from product code, and can be listed in order of code, price or stock
- Selling, restocking and removing products report problems with exceptions
- A report shows the total value of the stock and the products that are running low
- A class template is used for at least one reusable piece, such as a sorted report
Technologies
- C++
- Classes
- Operator overloading
- Templates
- map and vector
- sort
Step by step
- Write and test the Money class with its operators.
- Write Product with checked member functions for selling and restocking.
- Store products in a map, and add commands to add, sell, restock and remove them.
- Write the reports, sorting copies of the products with comparison functions.
- Write a small class template, such as a top-N list, and use it in a report.
- Report every bad command with an exception, caught in the command loop.
- Test selling out, unknown codes, and a report with no products.
Expected result
A working inventory manager that keeps exact amounts of money and never sells stock it does not have.
How it is evaluated
- Money is exact: no floating-point rounding errors appear in any total
- Stock can never become negative
- Reports are correct and sorted as asked
- Classes are small, const-correct and easy to read
Ways to improve it
- Record every sale with a date and show daily totals
- Add product categories with their own discount rules
- Load the starting stock from a file