diff options
| author | mavlushechka <mavlushechka@gmail.com> | 2021-11-21 16:30:47 +0500 | 
|---|---|---|
| committer | mavlushechka <mavlushechka@gmail.com> | 2021-11-21 16:30:47 +0500 | 
| commit | ed29fd0b5949e34c2368e790ab790e06ffeda3de (patch) | |
| tree | 596bc0d79a47ce3be31076ca156e01fc7bcac3fa /src/com/mavlushechka/tictactoe | |
| parent | cc9707b8341971e2def81a92a310cff91abb7883 (diff) | |
Changed players char constants to enum
Diffstat (limited to 'src/com/mavlushechka/tictactoe')
| -rwxr-xr-x[-rw-r--r--] | src/com/mavlushechka/tictactoe/TicTacToe.java | 11 | 
1 files changed, 4 insertions, 7 deletions
| diff --git a/src/com/mavlushechka/tictactoe/TicTacToe.java b/src/com/mavlushechka/tictactoe/TicTacToe.java index a627585..b9b12e9 100644..100755 --- a/src/com/mavlushechka/tictactoe/TicTacToe.java +++ b/src/com/mavlushechka/tictactoe/TicTacToe.java @@ -2,18 +2,15 @@ package com.mavlushechka.tictactoe;  import com.mavlushechka.tictactoe.exceptions.IncorrectCoordinatesDiapasonException;  import com.mavlushechka.tictactoe.exceptions.OccupiedCellException; +import com.mavlushechka.tictactoe.players.Player;  import java.util.Scanner;  public final class TicTacToe { -    private static final char FIRST_PLAYER = 'X'; - -    private static final char SECOND_PLAYER = 'O'; -      private final char[][] cells = {{' ', ' ', ' '}, {' ', ' ', ' '}, {' ', ' ', ' '}}; -    private char currentPlayer = FIRST_PLAYER; +    private char currentPlayer = Player.FIRST.SYMBOL;      private boolean gameFinished = false; @@ -34,7 +31,7 @@ public final class TicTacToe {                  When all 9 squares are full, the game is over.                  First player is %c. Players must enter the y and x coordinates separated by a space. -                """, FIRST_PLAYER, SECOND_PLAYER, FIRST_PLAYER); +                """, Player.FIRST.SYMBOL, Player.SECOND.SYMBOL, Player.FIRST.SYMBOL);      }      private void showCells() { @@ -81,7 +78,7 @@ public final class TicTacToe {      private void move(byte y, byte x) {          cells[y][x] = currentPlayer; -        currentPlayer = (currentPlayer == FIRST_PLAYER) ? SECOND_PLAYER : FIRST_PLAYER; +        currentPlayer = (currentPlayer == Player.FIRST.SYMBOL) ? Player.SECOND.SYMBOL : Player.FIRST.SYMBOL;          showCells();          checkLines(); |