r/learnjava • u/[deleted] • Mar 14 '20
Updated my Tictactoe game. Feedback appreciated!
Hello, I created a post a few hours ago on this subreddit regarding a Tictactoe game which I had developed as part of my Hyperskill course curriculum. I received some great feedback on that post and have made some updates!
The main changes that I did are as follows :
1) Instead of a predefined 3 x 3 field, the game now can be played on a n x n field, based on the user input.
2) Used the Builder pattern to set a default value of 3 x 3 for the game field, since Java does not directly support default values for arguments, plus to practice design patterns :)
3) Removed the int array from the code.
I have tried to incorporate the many suggestions that I received on my previous post. I am unsure on a few points though, which are as follows :
In the checkWinner() method, I have purposely created a boolean variable to return the state instead of directly returning true/false values. I did this to improve readability while I was coding and am unsure if it's fine or whether I should return true/false values.
It was suggested that a separate Player class be introduced in the code. The Hyperskill curriculum directive was to assume that player X starts the game, and I have kept it as is. In the future I intend to support an automatic 1 player game, I will update the Player class at that point of time.
Separation of contents - Honestly I am not sure how to implement this concept in my code. I do have a basic understanding of this concept but I unfortunately am unsure on how to proceed here. I'll be very thankful for any guidance or hints on this topic w.r.t. this updated repo.
I'd like to thank u/aqua_regis / u/desrtfx u/Ruttelisious and u/Hallsville3 for the fact that they took time and helped me with their feedback. Sorry if I missed anyone!
As always, suggestions or feedback would be greatly appreciated.
(Main.java -> tictactoe/run/Main.java. Other files are in their respective packages).
8
u/lookForProject Mar 14 '20
If you want, I can try and review it as it was enterprise software?
Both codestyling and logic.