Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

Memory Game

A Java console game where players flip two cards at a time to find matching pairs. The board has 8 cards (4 pairs) hidden behind question marks. When cards match, they stay revealed; when they don't, they flip back. The goal is to find all 4 pairs by remembering card positions.

Run

cd memory-game
javac src/App.java
java -cp src App

Sample Input & Output

Welcome to the Memory Game!
  1   2   3   4   5   6   7   8
| ? | ? | ? | ? | ? | ? | ? | ? |
Enter first card position (1-8) or -1 to quit: 1
  1   2   3   4   5   6   7   8
| A | ? | ? | ? | ? | ? | ? | ? |
Enter second card position (1-8) or -1 to quit: 3
  1   2   3   4   5   6   7   8
| A | ? | B | ? | ? | ? | ? | ? |
Oops! Not a match. Try again!
  1   2   3   4   5   6   7   8
| ? | ? | ? | ? | ? | ? | ? | ? |
Enter first card position (1-8) or -1 to quit: abc
Invalid position! Enter 1-8 only.
Enter first card position (1-8) or -1 to quit: 1
  1   2   3   4   5   6   7   8
| A | ? | ? | ? | ? | ? | ? | ? |
Enter second card position (1-8) or -1 to quit: 5
  1   2   3   4   5   6   7   8
| A | ? | ? | ? | A | ? | ? | ? |
Awesome! You got a match!
  1   2   3   4   5   6   7   8
| A | ? | ? | ? | A | ? | ? | ? |
Enter first card position (1-8) or -1 to quit: 2
  1   2   3   4   5   6   7   8
| A | B | ? | ? | A | ? | ? | ? |
Enter second card position (1-8) or -1 to quit: 6
  1   2   3   4   5   6   7   8
| A | B | ? | ? | A | B | ? | ? |
Awesome! You got a match!
  1   2   3   4   5   6   7   8
| A | B | ? | ? | A | B | ? | ? |
Enter first card position (1-8) or -1 to quit: 3
  1   2   3   4   5   6   7   8
| A | B | C | ? | A | B | ? | ? |
Enter second card position (1-8) or -1 to quit: 7
  1   2   3   4   5   6   7   8
| A | B | C | ? | A | B | C | ? |
Awesome! You got a match!
  1   2   3   4   5   6   7   8
| A | B | C | ? | A | B | C | ? |
Enter first card position (1-8) or -1 to quit: 4
  1   2   3   4   5   6   7   8
| A | B | C | D | A | B | C | ? |
Enter second card position (1-8) or -1 to quit: 8
  1   2   3   4   5   6   7   8
| A | B | C | D | A | B | C | D |
Awesome! You got a match!
Congratulations, you won!