TicTacToe 5x5 in Java console : <p>I'm writing a game of noughts and crosses with a 5x5 console sales.
Faced with the following problems:</p>

<p>1) For some reason, game can be finished after the first stroke and the second, depending on what type of cell chosen. For example, when i choosing 0 and 6 cells, X already a winner. Or if you choose the 22nd, the game also ends.</p>

<p>2) A beautiful cell borders. It turns out to make nice or for single-digit or double-digit for. How to make a beautiful table??
Code:</p>

<pre><code>package game;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class GameField {

    static int [] canvas = {0,0,0,0,0,
                            0,0,0,0,0,
                            0,0,0,0,0,
                            0,0,0,0,0,
                            0,0,0,0,0}; 

    public static void main(String[] args){

        boolean b;
        boolean isCurrentX = false;
        do {
            isCurrentX = !isCurrentX;
            drawCanvas();
            System.out.println("Ходит " + (isCurrentX ? "X" : "O"));
            int n = getNumber();
            canvas[n] = isCurrentX ? 1 : 2;
            b = !isGameOver(n);
            if (isDraw()){
                System.out.println("Draw");
                return;
            }
        } while (b);
        drawCanvas();
        System.out.println();

        System.out.println("ПОбедитель: " + (isCurrentX ? "X" : "O") + "!");
    }

    static int getNumber(){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while (true){
            try {
                int n = Integer.parseInt(reader.readLine());
                if (n &gt;= 0 &amp;&amp; n &lt; canvas.length &amp;&amp; canvas[n]==0){
                    return n;
                }
                System.out.println("Выберите свободное поле и введите его порядковый номер");
            } catch (NumberFormatException e) {
                System.out.println("Пожалуйста, введите порядковый номер клетки");
            } catch (IOException e) {
            }
        }
    }

    static boolean isGameOver(int n){
        //
        //  0   1  2  3 4
        //  5   6  7  8 9 
        // 10 11 12 13 14
        // 15 16 17 18 19
        // 20 21 22 23 24

        int row = n-n%5; 
        if (canvas[row]==canvas[row+1] &amp;&amp;
                canvas[row]==canvas[row+2] &amp;&amp;
                        canvas[row]==canvas[row+3] &amp;&amp;
                                canvas[row]==canvas[row+4]) return true;

        int column = n%5; 
        if (canvas[column]==canvas[column+5])
            if (canvas[column]==canvas[column+10])
                if (canvas[column]==canvas[column+15])
                    if (canvas[column]==canvas[column+20])return true;

        if (n%2!=0) return false;

        if (n%4==0){

            if (canvas[0] == canvas[6] &amp;&amp;
                    canvas[0] == canvas[12] &amp;&amp;
                            canvas[0] == canvas[18] &amp;&amp;
                                    canvas[0] == canvas[24]) return true;
            if (n!=4) return false;
        }
        return canvas[2] == canvas[4] &amp;&amp;
                canvas[2] == canvas[8]&amp;&amp;
                        canvas[2] == canvas[12]&amp;&amp;
                                canvas[2] == canvas[16]&amp;&amp;
                                        canvas[2] == canvas[20];
    }

    static void drawCanvas(){
        System.out.println("     |     |     ");
        for (int i = 0; i &lt; canvas.length; i++) {
            if (i!=0){
                if (i%5==0) {
                    System.out.println();
                    System.out.println("_____|_____|_____");
                    System.out.println("     |     |     ");
                }
                else
                    System.out.print("|");
            }

            if (canvas[i]==0) System.out.print("  " + i + "  ");
            if (canvas[i]==1) System.out.print("  X  ");
            if (canvas[i]==2) System.out.print("  O  ");
        }
        System.out.println();
        System.out.println("     |     |     ");
    }

    public static boolean isDraw() {
        for (int n : canvas) if (n==0) return false;
        return true;
    }
}
</code></pre>
