import javax.swing.JOptionPane; public class circle{ //Instance variables /* * 2D array of chars for the board */ public static void main(String[] args) { circle o = new circle(); o.print(); } private char[][] board; /** * Creates a board where each * square holds the underline '_' character. */ public circle(){ board = new char[2][3]; for (int row = 0; row < 2; row ++){ for (int col = 0; col < 3; col++){ board[row][col] = '_'; } // end of inner loop } // end of outer loop } public char get(int row, int col){ return board[row][col]; } public void print(){ int col; System.out.println(); for (int row = 0; row < 2; row ++){ if(row == 0){ System.out.print("Start"+ "\t"); } else { System.out.print("Finish"+ "\t"); } for (col = 0; col < 3; col++){ System.out.print(board[row][col] + " "); } // end of inner loop System.out.println(); } // end of outer loop } }
This prints:
Start _ _ _
Finish _ _ _
I was wondering how i could change the "_" to "X" if the user inputs a correct answer :S