Thabani Biyela, ACA

Logo

View the Project on GitHub thabanibiyela/memory-game

๐Ÿง  Memory Card Matching Game

Flip. Match. Forget. Repeat.

A Java memory card game with multi-player support, persistent high scores, and game replay. Built as OOP coursework โ€” turned out pretty fun.


๐ŸŽฎ Whatโ€™s the game?

Classic memory card game. Cards are face-down. You flip two at a time. If they match, they stay revealed. If not, they flip back โ€” and youโ€™d better remember where they were. Clear the whole board to win.

Two flavours:


โœจ Features


๐Ÿ•น๏ธ How to Play

  1. Run from MainDriver.java
  2. Register or log in (5โ€“9 character password, alphanumeric username)
  3. Pick your game type, board dimensions, and card flash time
  4. Flip cards by entering coordinates: (row, col) (row, col)
  5. Match everything to finish โ€” new high score? Itโ€™s saved automatically

๐Ÿ† Scoring

The faster and more efficiently you play, the higher your score:

baseScore = (tilesยฒ) - ((moves - perfectFlips)ยฒ) - exposureTime
finalScore = baseScore ร— 200,000

๐Ÿ—‚๏ธ Project Structure

src/com/oop/memorygame/
โ”œโ”€โ”€ drivers/
โ”‚   โ”œโ”€โ”€ MainDriver.java          # Entry point, menus, game loop
โ”‚   โ”œโ”€โ”€ Constants.java           # Emoji list, screen config, validation rules
โ”‚   โ”œโ”€โ”€ BoardThread.java         # Board display + player input (threaded)
โ”‚   โ”œโ”€โ”€ MoveRecorderThread.java  # Records moves in parallel
โ”‚   โ””โ”€โ”€ Replayer.java            # Replays saved games
โ”œโ”€โ”€ gameobjects/
โ”‚   โ”œโ”€โ”€ Tile.java                # Abstract tile (position, state, matched?)
โ”‚   โ”œโ”€โ”€ EmojiTile.java           # ๐Ÿ™‚ Emoji variant
โ”‚   โ”œโ”€โ”€ LatinTile.java           # ๐Ÿ”ค Letter variant
โ”‚   โ”œโ”€โ”€ NewGameBoard.java        # Randomly generates a fresh board
โ”‚   โ”œโ”€โ”€ LoadGameBoard.java       # Loads board, validates moves, handles matching
โ”‚   โ”œโ”€โ”€ Move.java                # One move = two tile coordinates
โ”‚   โ”œโ”€โ”€ MoveCollection.java      # Full move history for a session
โ”‚   โ”œโ”€โ”€ Player.java              # Name, password, high score
โ”‚   โ””โ”€โ”€ PlayerGroup.java         # Rankings + leaderboard management
โ”œโ”€โ”€ filemodifiers/
โ”‚   โ”œโ”€โ”€ Savable.java             # Interface: "I can be written to a file"
โ”‚   โ”œโ”€โ”€ FileModifier.java        # Abstract read/write base
โ”‚   โ””โ”€โ”€ SortedFileModifier.java  # Sorted persistence via TreeSet
โ””โ”€โ”€ userinputs/
    โ”œโ”€โ”€ GameParameter.java        # Base class for validated inputs
    โ”œโ”€โ”€ GameTypeParameter.java    # Emoji or Latin?
    โ”œโ”€โ”€ DimensionsParameter.java  # Valid board dimensions
    โ”œโ”€โ”€ FlashTime.java            # How long cards stay visible
    โ””โ”€โ”€ InputPlayerName.java      # Alphanumeric, max 8 chars

๐Ÿ’พ Data Files

File Whatโ€™s in it
boardfile.txt Current board state
playersfile.txt Players, scores, passwords (semicolon-delimited)
movecollection.txt Last gameโ€™s move history
gamesettings.txt Saved game configuration

๐Ÿ› ๏ธ Tech Stack


๐Ÿงช Tests

Test/
โ”œโ”€โ”€ PlayerTests.java
โ”œโ”€โ”€ GameBoardTest.java
โ”œโ”€โ”€ TileTests.java
โ”œโ”€โ”€ MoveTests.java
โ”œโ”€โ”€ MoveCollectionTests.java
โ””โ”€โ”€ PlayersGroupTest.java

Covers players, boards, tiles, moves, collections, and group rankings.