Valid Move method for Tic Tac Toe in Java -


i have got assignment develop tic tac toe game isvalidmove method creates trouble. replaces symbol after testing isvalidmove method. actually, never goes , checks 'if' condition in isvalidmove method.

public boolean executemove(string move, player p) {     int row;     int col;     row = (int)(move.charat(0)-'0');     col = (int)(move.charat(1)-'0');      if(isvalidmove(move) == false)       {         board[row-1][col-1]= p.getsymbol();         printboard();     }     return true; }  public boolean isvalidmove(string move) {     int row = (int)(move.charat(0)-'0');     int col = (int)(move.charat(1)-'0');         if(board[row-1][col-1] == ' ')         {             return true;         }     return false; } 

ps: if can tell me.. program enters name of players string prints address rather printing name.. do?

seems executemove() must return true if move legally performed. return true illegal moves.

public boolean executemove(string move, player p) {     int row;     int col;     row = (int)(move.charat(0)-'0');     col = (int)(move.charat(1)-'0');      boolean valid = isvalidmove(move);       // <-- remember move valid     if (valid) {         board[row-1][col-1] = p.getsymbol(); // <-- place symbol if move valid     }      printboard();     return valid; } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -