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.
cd memory-game
javac src/App.java
java -cp src AppWelcome 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!