Yahtzee Game

A Yahtzee game developed in Java and playable on the command line

Yahtzee Game cover

Key learnings

Java fundamentals including object-oriented programming and data structure implementation

Game logic design with systematic scoring algorithms and state management

Command-line interface development with input validation and user experience optimization

Description

This is the classic dice game Yahtzee, written in Java and played entirely in the terminal. Any number of players can join by entering their names, separated by commas, and the game then takes them through thirteen rounds of turns.

Each turn starts with the player's scorecard and a roll of five dice. You can reroll any of them twice by typing their positions, for example 1,2, or keep what you have. After every roll, the game lists the categories the dice currently fit and what each would score, so choosing is a matter of typing a number. If nothing fits, one category has to be crossed out instead, which the scorecard marks with an X.

A turn in progress: the scorecard on the left, the dice and the scoring options on the right

Scoring follows the standard rules, including the 35-point bonus for reaching 63 points in the upper section. After the last round, the game prints every scorecard and announces the winner.

End of a two-player game with both final scorecards and the winner

Reflection

This project was my first chance to apply the Java fundamentals I had been learning to something complete. It taught me how to split a program into classes with clear responsibilities: the game loop, the players, the dice, and the score.

The data structures are deliberately simple. Each player holds an array of five dice and an array of thirteen scores, where -1 marks a category that has not been used yet. A good share of the work went into the input handling: the prompts check what was typed and ask again, so dice outside 1 to 5, an out-of-range category, or one that is already used get rejected instead of corrupting the scorecard.

The scoring rules were the part that needed the most care. Each combination is its own small check over the dice, and unit tests for the dice and the scoring gave me a way to verify them without playing a full game every time.

Last updated: Nov 11, 2026