This project is a Vending Machine Simulator developed as part of the coursework for EEEE 2067 - Design and Implementation of Engineering Software. The simulator allows users to select and purchase items, view product availability and prices, and complete transactions using WeChat or Alipay. It also includes a maintenance mode for refilling items and generating sales reports.
The Vending Machine Simulator is designed to simulate the functionality of a high-tech vending machine. It displays products, prices, and available quantities, accepts payments, and provides an easy-to-use interface for both customers and operators.
- Display available products, prices, and quantities.
- Purchase multiple items in one transaction.
- Payment options: WeChat or Alipay.
- Operator-only maintenance mode for refilling items and generating daily sales reports.
- Sales report generation with output to a text file in
YY-MM-DD.txtformat.
The ProductItem class represents each item in the vending machine. It includes:
- Attributes
itemName: The name of the item.itemCost: Price of the item in yuan.itemQuantity: Quantity available for sale.
- Methods
- Constructor, destructor, copy constructor.
- Accessor and mutator functions for item attributes.
The VendingMachine class manages the overall operation of the vending machine. It includes:
- Attributes
- An inventory array initialized with the data in the provided initial state.
- Methods
menuDisplay(): Displays products, prices, and quantities; allows item selection and cancellation.buyItem(): Facilitates item purchasing, manages stock, and handles out-of-stock items.refill_Item(): Allows the operator to refill items up to a maximum quantity.salesReport(): Generates a sales report and exports it to a text file.- Additional utility functions and copy constructor.
- View the available items on the screen along with prices and quantities.
- Select items to add to the cart and choose a payment method.
- Complete the purchase and receive the selected items.
- Accessible by the operator with a password.
- Allows refilling items and generating a daily sales report in a text file.
The UML diagram illustrates the design of the ProductItem and VendingMachine classes. It is available in uml_diagram.pdf.
The project follows a multi-file program structure:
- Header Files:
ProductItem.h,VendingMachine.h - Source Files:
ProductItem.cpp,VendingMachine.cpp,main.cpp
- Utilizes arrays, pointers, and dynamic memory allocation.
- Ensures data encapsulation through private member variables and public accessor/mutator methods.