diff --git a/src/js/Game.js b/src/js/Game.js index 6995882..8b254dd 100644 --- a/src/js/Game.js +++ b/src/js/Game.js @@ -15,10 +15,21 @@ export class Game #state; /** - * Initializes a new instance of the {@link Game `Game`} class. + * The id of the element to add the board to. + * + * @type {string} */ - constructor() + id; + + /** + * Initializes a new instance of the {@link Game `Game`} class. + * + * @param {string} id + * The id of the element to add the board to. + */ + constructor(id) { + this.id = id; this.#state = new State(); } @@ -40,13 +51,10 @@ export class Game /** * Initializes the game. - * - * @param {string} id - * The id of the element to add the board to. */ - initialize(id) + initialize() { - let board = document.getElementById(id); + let board = document.getElementById(this.id); board.innerHTML = ""; for (let i = 0; i < 6; i++) @@ -78,7 +86,7 @@ export class Game { this.board[i][j] = this.state.currentPlayer; this.state.turnCount++; - this.initialize(id); + this.initialize(); }; board.appendChild(field); diff --git a/src/js/main.js b/src/js/main.js index c00150e..36ea495 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -12,8 +12,8 @@ let game; */ function initialize() { - game = new Game(); - game.initialize("board"); + game = new Game("board"); + game.initialize(); } initialize();