Hey! I'm trying to learn
java again and doing some exercises, I am struggling with understanding this task:
Write a code that handles tic-tac-toe game on a square board. I have a template like this:
my code:
rules: method setBoardSize should be called 1st, before calling setBoardSize, setO and setX should be ignored, calling toString() should return null, hasEmpty return false.
method setO - should set circle on board
method setX - should set X on board
method hasEmpty - return true untill board is full
method toString should generate actual board state and output smth like this (after calling System.out.println(reference to Test4)):
+-+-+-+
|O |X| |
+-+-+-+
| |X| |
+-+-+-+
| |O| |
+-+-+-+
program should communicate and ignore about wrong moves:
- 2 and more same moves (eg. Twice X in row)
- placing X/O outside the board
- placing X/O on a spot already taken
Starting position is (0,0) - upper left corner on board.
I do not need main method.
Thanks in advance for any help
!