A simple two-player console-based version of the classic card game Snap, built in Java.
When two consecutively dealt cards match in value, players must race to type "snap" within 2 seconds to win. The first player to do so correctly is declared the winner โ but hesitate too long, and the chance is lost!
-
Two-player alternating turns
-
๐ Fully shuffled deck logic
-
โณ Reaction-based SNAP logic with a 2-second timer
-
Simple and readable CLI interface
-
Modular code structure (Card, Deck, Player, CardGame, Snap)
-
Press Enter to deal a card on your turn.
-
If the current card value matches the previous one, a SNAP opportunity is triggered.
-
Each player is prompted in turn to type snap within 2 seconds.
-
If the first player is too slow or types incorrectly, the second player gets a chance.
-
If both players fail to snap correctly in time, the game continues.
-
The game ends when a player wins by snapping correctly or when the deck runs out.
- Clone or download the project
git clone git@github.com:Tannababy/naughts-crosses-game.git
- Open project in IDE. eg. InteliJ IDEA
- Navigate into project directory
cd cardGame-Snap - Compile the Code: Use the Java compiler to compile all your
.javafiles.javac -d out $(find src/main/java/snap.cardGame "*.java") - Run game
java -cp out snap.cardGame.App
A learning project to practice object-oriented programming, game logic, and console I/O handling in Java.