From f997236e7478f7ee7f9984aff3f8e8a46725271d Mon Sep 17 00:00:00 2001
From: JimmyTheCat <154287729+JimmyTheCatOwO@users.noreply.github.com>
Date: Thu, 9 Jan 2025 16:10:57 +0100
Subject: [PATCH] Javadoc Board, Player, Main and added turnEnd returns
 victoryCheck

---
 Board.java  | 51 +++++++++++++++++++++++++++++++++++----------------
 Main.java   | 11 ++++++++++-
 Player.java | 29 +++++++++++++++++++++++++++++
 3 files changed, 74 insertions(+), 17 deletions(-)

diff --git a/Board.java b/Board.java
index 8060fe8..6c5c616 100644
--- a/Board.java
+++ b/Board.java
@@ -1,6 +1,10 @@
+/**
+ * This class is an Object that defines the logical enviroment of the application.
+ */
 public class Board extends Thread {
     
-    /**This Array contains the Tiles on which the players draw.
+    /**
+     * This Array contains the Tiles on which the players draw.
      * The tiles are aranged two dimensionally in this form:
      * 0 1 2
      * 3 4 5
@@ -8,53 +12,66 @@ public class Board extends Thread {
      */
     Tile tiles[] = new Tile[9];
 
-    /**This Array contains the Players.
-     * 
+    /**
+     * This Array contains the Players.
      */
     Player players[] = new Player[2];
 
-    /**This Integer defines which character gets to draw first.
-     * 
+    /**
+     * This Integer defines which character gets to draw first.
      */
     int firstPlayer;
 
-    /**This Integer defines which character can currently draw on a tile.
-     * 
+    /**
+     * This Integer defines which character can currently draw on a tile.
      */
     int currentPlayer;
 
-    /**This Integer tracts the amount of marks that were already placed.
-     * 
+    /**
+     * This Integer tracts the amount of marks that were already placed.
      */
     int marks;
 
-    /**Constructor of the Board class.
-     * Creates the Tiles and Players and sets the player who starts the game.
+    /**
+     * Constructor of the Board class.
+     * Creates a board with new players and a set turn order.
      */
     Board() {
         for(int i = 0; i < players.length; i++) players[i] = new Player(i+1);
         firstPlayer = 0;
         initBoard();
     }
-
+   
+    /**
+     * Constructor of the Board class.
+     * Creates a board with set players and an inverted turn order.
+     * 
+     * @param players the players of the previous game.
+     * @param firstPlayer the first turn assignment of the previous game.
+     */
     Board(Player[] players, int firstPlayer) {
         this.players = players;
         this.firstPlayer = firstPlayer == 1 ? 0 : 1;
         initBoard();
     }
 
+    /**
+     * Creats the tiles and assigns the first turn.
+     */
     private void initBoard() {
         for(int i = 0; i < tiles.length; i++) tiles[i] = new Tile(0,0,0);
         currentPlayer = firstPlayer;
         marks = 0;
     }
 
-    /**Ends the turn by increasing the mark counter and changing the player.
+    /**
+     * Ends the turn by increasing the mark counter and changing the player.
      * Additionally it ends the game when certain conditions are met.
      */
-    public void turnEnd() {
+    public boolean turnEnd() {
         marks++;
-        if(marks > 4 && victoryCheck()) {
+        boolean victory = victoryCheck();
+        if(victory && marks > 4) {
             System.out.println("You win Player " + currentPlayer);
             players[currentPlayer].playerScoreInc();
         } else if(marks == 9) {
@@ -62,9 +79,11 @@ public class Board extends Thread {
         } else {
             currentPlayer = currentPlayer == 1 ? 0 : 1;
         }
+        return victory;
     }
 
-    /**Checks whether the current player has won the game.
+    /**
+     * Checks whether the current player has won the game.
      * 
      * @return current player won
      */
diff --git a/Main.java b/Main.java
index b0955d5..bdc7259 100644
--- a/Main.java
+++ b/Main.java
@@ -1,9 +1,18 @@
+/**
+ * Main class
+ * Starting point of the application.
+ */
 public class Main {
 
+    /**
+     * main methode
+     * Creates and calls the GameUI.
+     * 
+     * @param args
+     */
     public static void main(String[] args) {
         GameUI gui = new GameUI();
         gui.call(args);
-        //System.out.println("hi");
     }
 
 }
diff --git a/Player.java b/Player.java
index 37b2d27..38e21ea 100644
--- a/Player.java
+++ b/Player.java
@@ -1,21 +1,50 @@
+/**
+ * This class is an Object that contains and handles information regarding the users of the application.
+ */
 public class Player {
     
+    /**
+     * This Integer defines how often the player has won.
+     */
     private int playerScore;
+
+    /**
+     * This Integer defines what number is assigned to the player.
+     */
     private int playerNumber;
 
+    /**
+     * Constructor of the Player class.
+     * Creates a new player setting its @param playerNumber and @param playerScore .
+     * 
+     * @param playerNumber the number assigned to the player at point of creation.
+     */
     public Player(int playerNumber) {
         this.playerNumber = playerNumber;
         this.playerScore = 0;
     }
 
+    /**
+     * Returns the number assigned to the player.
+     * 
+     * @return the number assigned to the player.
+     */
     public int getPlayerNumber() {
         return playerNumber;
     }
 
+    /**
+     * Returns the score of the player.
+     * 
+     * @return the score of the player.
+     */
     public int getPlayerScore() {
         return playerScore;
     }
 
+    /**
+     * Increments the players score on call.
+     */
     public void playerScoreInc() {
         playerScore++;
     }
-- 
GitLab