he issue i'm having when create board of minesweeper clone, not carry on guess location round round on board placing x there should still g previous round, code follows.
int array x , y coordinates user guess, int array bx , bomb coordinates, bombs how many bombs being played with, , turn turn count.
public void board(int[] x, int[] y, int[]bx, int[]by, int bombs, int turn) { char[][] board = new char[10][10]; char[] guess = new char[(100-bombs)]; int g = 0; for(int p = 1; p<11;p++) system.out.print(" "+p +" |"); (int row = 0; row < board.length; row++) { (int col = 0; col < board.length; col++) { board[row][col] = 'x'; board[y[turn]][x[turn]] = 'g'; for(g = 0; g<board.length; g++) { guess[g] = 'g'; }//end if (x[col] == col && y[row] == row) system.out.print(guess[g]); else system.out.print(board[row][col]); } // end nested loop system.out.println();// space out lines board } // end loop // end randx/y loop checkinput(x,y,bx,by,bombs,turn); }
first of think there syntax error in code. missing curly bracket @ top after first loop (so seems there bracket @ end.) these syntax errors can cause p variable not iterate not looping through guesses.
try fixing , give update.
hope helps.
:)
update 1:
i think if want display guesses have put if/else clause within loop prints each time g iterates. or else, print last value of guess[g] board.length - 1.
Comments
Post a Comment