I am creating a game. I have two player classes, a gameState class and a gamePlay class (and a few other classes).
-computerPlayer extends Player
-keyboardPlayer extends Player
Player red = new keyboardPlayer(); Player yellow = new computerPlayer();
I have a method move(int mov) which adds to a multidimensional array board[i][j] = turn(); in gameState. Both player classes use it, the only difference is keyboard has a int keyboard input and computer is a random int. When I used the move method, however (which also prints the current board (as 2D array in the terminal)) something odd happened. Each time the board printed itself only the moves from that player displayed (ie all reds moves and its past moves), instead of red and yellow on one board. There is only one array and i am not aware of copying it. So I have a red board - with all reds previous moves - and the new one, or on yellows turn, a yellow board with all yellow previous moves - and the new one. Why is this? All that is in each player class is in input type (keyboard or random) and
double number = (Math.random()*20); int mov = (int) number; gameState.move(mov).
move would work fine if I didnt have to have two player classes. The only problem is they dont print on the same board/Not in the same array.