A console-based C++ application that simulates a digital game store — inspired by platforms like Steam and Epic Games. Built as a 3rd semester OOP course project using structured programming concepts.
| Roll Number | Name |
|---|---|
| BCSF24M017 | Umer Farooq Afridi |
| BCSF24M032 | Ayesha Bint e Younus |
| BCSF24M046 | Gulshan Mushtaq |
The system allows customers to browse, search, filter, and purchase video games from a pre-defined inventory stored in a text file. An Admin (password-protected) can manage the inventory by adding, removing, or updating game prices.
- Demonstrate practical use of structured programming concepts
- Implement arrays, dynamic memory allocation, and text file handling
- Build a menu-driven system that interacts with data stored in external files
games.txt— main game database (admin-managed)history.txt— created on first purchase, updated on every checkout
- Design the project so it can easily be converted to OOP later
The admin prepares and manages games.txt containing all game information.
File format:
Name, Genre, Price
Batman: Arkham Knight, Action, 6500
The customer interacts with the store through a menu-driven interface with the following options:
- View all available games
- Filter games by genre (e.g. Action, Sports, Adventure)
- Filter games by price range
- Search a specific game by name
- Add a game to cart
- Remove a game from cart
- View items in the cart
- Checkout and generate bill
- Exit the program
Upon checkout, purchase details are saved to history.txt for record keeping.
| File | Type | Purpose |
|---|---|---|
games.txt |
Text | Stores all game information (predefined and admin-editable) |
history.txt |
Text | Stores user purchase records and bill details |
| Concept | Application |
|---|---|
| Arrays | Store and display game data |
| Dynamic Memory Allocation | Manage cart and number of available games |
| Text File Handling | Read from games.txt, write purchase history to history.txt |
| Functions | Handle each menu operation separately |
Total Global Functions: 27 — ensuring full modularity across the system
PROGRAM START
│
├── loadGamesFromTextFile() → Load games.txt into memory (dynamic array, cap: 100)
│
└── MAIN MENU LOOP
├── 1. Admin Mode
│ ├── handleAdminLogin() → Password check (hardcoded: 112356)
│ └── adminMenu()
│ ├── Add Game
│ ├── Remove Game
│ ├── Update Price
│ ├── View All Games
│ └── Save & Exit → saveGamesToTextFile()
│
├── 2. Customer Mode
│ └── customerMenu()
│ ├── Browse / Search / Filter Games
│ ├── Add to Cart
│ ├── Remove from Cart
│ ├── View Cart
│ ├── Checkout → generateOrderID() → saveOrderToHistory()
│ └── View Purchase History
│
└── 3. Exit
| Function | Purpose |
|---|---|
handleAdminLogin() |
Authenticates admin via hardcoded password |
adminMenu() |
Displays and routes admin options |
addGame() |
Adds new game after validating name, genre, and price |
removeGame() |
Removes game by name, shifts array elements left |
updateGamePrice() |
Finds game and updates its price (range: 0–10000) |
viewAllGames() |
Displays all games in formatted table |
saveGamesToTextFile() |
Persists current inventory to games.txt |
findGameIndex() |
Case-insensitive search — returns index or -1 |
toLowerCase() |
Converts string to lowercase for comparison |
selectGenre() |
Lets user choose from 17 predefined genres |
resize() |
Doubles array capacity when full (100→200→400...) |
| Function | Purpose |
|---|---|
customerMenu() |
Displays and routes customer options |
inputPriceRange() |
Optional price filter (Y/N), sets min/max range |
filterAllGames() |
Displays all games within price range |
filterByGenre() |
Displays games matching genre AND price range |
isPriceInRange() |
Returns true if price falls within min–max |
addToCart() |
Adds game to cart — prevents duplicates, auto-resizes |
removeFromCart() |
Removes game from cart, shifts elements left |
viewCart() |
Displays cart contents with total item count |
checkout() |
Processes purchase, generates order ID, clears cart |
calculateTotal() |
Sums all prices in current cart |
generateOrderID() |
Generates unique 5-digit random order ID |
isOrderIDUnique() |
Checks history.txt to confirm ID not already used |
saveOrderToHistory() |
Appends order details to history.txt |
Dynamic Arrays Used:
games[]— Main inventory (starts at 100, doubles as needed)cart[]— Shopping cart (starts at 5, doubles as needed)
Resize Strategy: Capacity doubles when full → old array deleted after copying → no memory leaks
Cleanup: Both arrays deleted at program end via delete[]
| Feature | Implementation |
|---|---|
| Case-insensitive search | All comparisons use toLowerCase() |
| Duplicate prevention | Admin can't add existing game; customer can't add same game to cart twice |
| Input validation | Price ranges enforced (0–10000); invalid menu input loops until corrected |
| Data persistence | Games saved to games.txt on admin exit; orders appended to history.txt on checkout |
| Dynamic memory | Arrays auto-resize when capacity is reached |
| Unique Order IDs | 5-digit random numbers verified against history before assignment |
Steps: Run → Admin (pw: 112356) → View All Games
Expected: All 135 games displayed. First: Batman: Arkham Knight (Action, 6500) | Last: Borderlands 2 (Shooter, 3000)
Input: Name: Assassin's Creed Mirage | Genre: Action | Price: 7000
Expected: "Game added successfully." | Total becomes 136
Input: Try to add GTA V
Expected: "This game already exists." — system rejects without prompting for genre/price
Input: Game: Valorant | New Price: 5000
Expected: "Price updated." | Valorant displays Rs.5000 in view
Input: Game: Left 4 Dead 2
Expected: "Game removed." | Total becomes 135 | Saved to games.txt on exit
Input: Price filter: N | Mode: Show All
Expected: All 135 games displayed
Input: Price filter: Y | Min: 0 | Max: 2000
Expected sample output:
Rocket League | Sports | Rs.0
Fortnite | Online | Rs.0
Cuphead | Action | Rs.1500
Hollow Knight | Metroidvania | Rs.1500
Dead Cells | Action | Rs.2000
Rainbow Six Siege | Shooter | Rs.2000
Input: Price: 5000–10000 | Genre: Action
Expected sample output:
Batman: Arkham Knight | Action | Rs.6500
Marvel's Spider-Man Remastered | Action | Rs.7500
Ghost of Tsushima | Action | Rs.9000
God of War Ragnarok | Action | Rs.10000
All results must satisfy both conditions (Action genre AND price 5000–10000)
| Input | Expected |
|---|---|
Minecraft Java Edition |
"Minecraft Java Edition added to cart successfully!" |
The Witcher 3 |
"The Witcher 3 added to cart successfully!" |
Hollow Knight |
"Hollow Knight added to cart successfully!" |
Input: Add Minecraft Java Edition again
Expected: "Minecraft Java Edition is already in your cart!"
===== YOUR CART =====
Minecraft Java Edition | Sandbox | Rs.5000
The Witcher 3 | RPG | Rs.5000
Hollow Knight | Metroidvania | Rs.1500
Total items: 3
Input: Remove The Witcher 3
Expected: "The Witcher 3 removed from cart." | Cart now shows 2 items
Expected flow:
===== CHECKOUT =====
Total Amount: Rs.6500
Confirm purchase? (Y/N): Y
Purchase successful!
Your Order ID: 47382
Thank you for shopping with us!
Cart cleared after successful checkout
--- Purchase History ---
Order ID: 47382
Items Purchased:
Minecraft Java Edition - Rs.5000
Hollow Knight - Rs.1500
Total Amount: Rs.6500
Steps: Add GTA V + Cyberpunk 2077 → Checkout
Expected: New unique 5-digit order ID different from previous order | Both orders visible in history
Steps: Exit program → Restart → Admin → View All Games
Verification checklist:
- Total games: 135
-
Assassin's Creed Miragestill present (added in Test 2) -
Left 4 Dead 2still absent (removed in Test 5) -
Valorantprice: Rs.5000 (updated in Test 4) - Both purchase orders still in
history.txt
When converted to Object-Oriented Programming, the following upgrades are planned:
Customer,Game,Cart, andStorewill become classes- Support for multiple customers with unique purchase histories
- Discount system for frequent buyers or large purchases
- Option to rate or review games
# Compile
g++ main.cpp -o GameStore
# Run
./GameStore # Linux/macOS
GameStore.exe # WindowsMake sure
games.txtis in the same directory as the executable before running.
Umer Farooq Afridi BS Computer Science — University of the Punjab, Lahore 🔗 LinkedIn | 🐙 GitHub