Skip to content

Repository files navigation

Vending-Machine

Vending Machine Simulator

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.

Table of Contents

Overview

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.

Features

  • 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.txt format.

Classes

ProductItem Class

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.

VendingMachine Class

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.

Usage

User Guide

  1. View the available items on the screen along with prices and quantities.
  2. Select items to add to the cart and choose a payment method.
  3. Complete the purchase and receive the selected items.

Maintenance Mode

  • Accessible by the operator with a password.
  • Allows refilling items and generating a daily sales report in a text file.

Implementation Details

UML Diagram

The UML diagram illustrates the design of the ProductItem and VendingMachine classes. It is available in uml_diagram.pdf.

Code Structure

The project follows a multi-file program structure:

  • Header Files: ProductItem.h, VendingMachine.h
  • Source Files: ProductItem.cpp, VendingMachine.cpp, main.cpp

Advanced Concepts

  • Utilizes arrays, pointers, and dynamic memory allocation.
  • Ensures data encapsulation through private member variables and public accessor/mutator methods.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages