Circular Linked List Game

Launched May 2023

Tags

  • Back End
  • Data Structures and Algorithms
  • Documentation
  • Java
  • Software Development
  • Unit Testing

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.

Class diagram, showing various classes and interfaces connected with arrows to show relationships, including Player, FirstTo100 (game), CircularLinkedList (class and interface), Node, Iterator, and Iterable.

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.

Object diagram, showing FirstTo100 referencing a CircularLinkedList and its nodes which contains Player objects, with arrows to show the direction of data flow.

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.

IntelliJ code editor shows Players being added to a CircularLinkedList, terminal has printed 3 rounds and each Player's score on their turn, ending with Lilac winning.

Thanks for checking out my project!

Back to Portfolio

Thank you!

Thanks for checking out my work! If you've got a project or job you think suits me, contact me here, by email, or on LinkedIn.

Contact Me

Thanks for dropping by!

Back to top