I need help creating a TicTacToe game programmed in JAVA It

I need help creating a Tic-Tac-Toe game programmed in JAVA. It has to be a player vs computer and the board of the Tic-Tac-Toe has to be a 1D (one-dimension).

Requirements: Don\'t use infinite loops: for(;;) while(true)

Solution

class TicTacToe {

    public static final int SIZEOFBOARD = 9;

    public enum PlyerTp {

        INVALID, NONE, X, O

    };

    private PlyerTp[] board;

    private PlyerTp winer;

    private int trn;

    public TicTacToe() {

        board = new PlyerTp[SIZEOFBOARD];

        for (int i = 0; i < SIZEOFBOARD; i++) {

            board[i] = PlyerTp.NONE;

        }

        winer = PlyerTp.NONE;

        trn = 0;

    }

    private boolean isValidLocation(int loc) {

        /* type code for location */

        return false;

    }

    public boolean setValue(PlyerTp value, int loc) {

        if (!isValidLocation(loc)) {

            return false;

        }

        board[loc] = value;

        return true;

    }

    public PlyerTp getValue(int loc) {

        if (!isValidLocation(loc)) {

            return PlyerTp.INVALID;

        }

        return board[loc];

    }

    private boolean playerWon(PlyerTp value) {

        /* type code for winning*/

        return false;

    }

    // public gameOver(){ } for game quit

    private boolean boardFull() {

        return trn == SIZEOFBOARD;

    }

}

I need help creating a Tic-Tac-Toe game programmed in JAVA. It has to be a player vs computer and the board of the Tic-Tac-Toe has to be a 1D (one-dimension). R
I need help creating a Tic-Tac-Toe game programmed in JAVA. It has to be a player vs computer and the board of the Tic-Tac-Toe has to be a 1D (one-dimension). R

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site