Java Grid Class -
i trying make java grid w/ intended output as:
but output off 1 in looks this: . suggestions?
public class grid { private int rows = 0; private int columns = 0; private string [] [] grid; public grid(int rows, int columns){ this.rows = rows; this.columns = columns; grid = new string [rows] [columns]; initializegrid(); } public void initializegrid(){ (int = 0; < rows; i++){ (int j = 0; j < columns; j++) { grid [i] [j] = "| "; } } } public void printgrid(){ system.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); (int = 0; < rows; ++i){ system.out.println("|"); (int j = 0; j < columns; ++j){ system.out.print(grid[i][j] + " "); } } system.out.println(); system.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"); } }
looks should have method public void printgrid(){ system.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); (int = 0; < rows; ++i){ (int j = 0; j < columns; ++j){ system.out.print(grid[i][j] + " "); } system.out.println("|"); }
Comments
Post a Comment