
Circular Linked List Game
May 2023
Java project that implements a generic circular linked list and demonstrates its functionality by iterating through each player in the list to model taking turns in a game. During their turn, each player rolls two dice and adds them to their score, and the first to reach 100 wins.
In order to improve my understanding of data structures, I implemented a circular linked list that accepts a generic type for reusability. I started by creating a class diagram in order to define each class’s fields, methods, interfaces, and relationships.

I also made an object diagram to clarify the structure of the circular linked list and its nodes, and how data flows through the program.

The list is made up of generic Node objects which reference their data and the next Node. The final Node points to the first Node. This adds some complexity to removing and adding Nodes. Rather than for loops, iteration is performed with a generic Iterator since there are no indexes as there would be in an array.
Once the linked list was complete and fully tested using JUnit, I implemented and tested the Player class. The FirstTo100.main() method runs the game, using random numbers to represent the dice rolls and outputting the results of each turn and the final winner. Each time main is run, it results in a different outcome.

Thanks for checking out my project!
Thanks for checking out my project!
Back to Portfolio