← Back to Portfolio

Vending Machine Simulator

Advanced C++14 simulator built without STL — custom linked lists, the command pattern, manual memory management, and Valgrind-verified zero leaks.

C++14 Custom ADTs Command Pattern Valgrind Verified
View Code
Vending Machine Project

Jump to Section

16+
Test Suites
8
Command Classes
8
Coin Denominations
0
Memory Leaks (Valgrind)
Project Overview

A fully-functional C++14 vending machine for a fictional pastry company, focused on robust programming, clean code, and dynamic memory management. Operates entirely in a console environment with persistent file-backed storage.

  • Product display, purchases, stock management, coin handling, and admin operations
  • Strict input and file validation with meaningful error messages
  • Custom singly & doubly linked lists built from scratch (no STL containers)
  • Manual new/delete verified leak-free with Valgrind
Custom Data Structures
  • Abstract LinkedList base class with virtual printLL, findItem, saveLL, resetStock, remove, addLL, and deleteLL
  • LinkedListSingle — singly-linked list for inventory traversal
  • LinkedListDouble — doubly-linked list with prev/next pointers enabling reverse display
  • Node / NodeD classes encapsulating product data (ID, name, description, price, on-hand quantity)
  • Strategy-style runtime switching between the two list implementations
Core Features

Product Management

Display inventory ascending/descending, add items, remove stock, and track availability.

Transactions

Exact-change, insufficient-funds detection, out-of-stock handling, and transaction abort.

Coin System

Eight denominations (5¢ – $10) with a greedy change-dispensing algorithm.

File Persistence

Validated stock.dat / coins.dat with strict format checking.

Admin Functions

Reset coins, restock, reverse-display inventory, and abort transactions.

Runtime List Switching

Toggle between single and doubly linked lists at runtime via the strategy pattern.

Architecture
  • VendingMachine — core orchestrator managing state and command dispatch
  • Command Pattern — eight command classes (Abort, DisplayItem, PurchaseItem, Save, AddItem, RemoveItem, DisplayCoins, ResetCoins)
  • Menu — UI layer for command selection
  • Coin / Price — currency representation and change calculation
  • Helper — static validation utilities for stock/coin formats and input parsing
Testing & Quality Assurance
  • 16+ test suites covering all major features and edge cases
  • Functional & purchase tests — exact change, insufficient funds, out-of-stock, invalid selection
  • Admin tests — coin reset, restock, forward/reverse display, add/remove items
  • Edge cases — malformed files, invalid delimiters, negative values, empty input
  • Memory safety — zero leaks across all operations, verified by Valgrind