This project is a multi-user Vending Machine system that allows customers to add products to a cart, view the cart, and proceed to checkout, while an owner can restock products. The system is implemented in C++ with file-based inventory management and supports concurrency for safe transactions.
-
Customer Mode (Buyer)
- View available products with price and stock
- Add products to cart with a specified quantity
- Prevents adding more items than available stock
- View cart with total price breakdown
- Secure checkout with cash payment and automatic stock updates
-
Owner Mode
- View all products and their stock levels
- Restock products dynamically
- Update product pricing if needed
-
File-based Inventory Management
input.txtstores product details (ID, Name, Price, Stock)profit.txtmaintains transaction history- Updates stock levels dynamically after purchases
- C++ compiler (GCC or Clang)
- Git (for version control)
- Clone the repository:
git clone https://github.com/Paras20222/Vending_Machine cd Vending_Machine - Compile the project:
g++ -o vending Vending.cpp -pthread
- Run the program:
./vending
Vending_Machine/
├── model.h # Defines Product, Item, and Cart classes
├── buyer.h # Implements Buyer functionalities
├── owner.h # Implements Owner functionalities
├── Vending.cpp # Main execution file
├── input.txt # Stores product inventory
├── profit.txt # Transaction records
├── README.md # Project documentation
- Start the vending machine.
- Select Buyer Mode.
- View available products.
- Choose a product and specify quantity.
- Add to cart (checks stock availability automatically).
- Checkout with payment (updates stock in
input.txt).
- Start the vending machine.
- Select Owner Mode.
- View all products and stock levels.
- Restock or update product prices.
- Changes reflect in
input.txt.
- Invalid product selection: Ensures input is within the available product list.
- Quantity validation: Prevents exceeding stock limits.
- File I/O safety: Uses temporary files for atomic updates.
- Concurrency Handling: Uses
mutexfor safe multi-threaded operations.
- GUI Interface using Qt or GTK for better user interaction.
- Database Integration instead of file storage for scalability.
- Card Payment Simulation for a more realistic experience.
- Admin Panel with analytics and sales tracking.
Feel free to fork and contribute! Submit a pull request with detailed descriptions of changes.
This project is open-source under the MIT License.
Developed by Paras Kumar Sharma 🚀