Question: i have a Java code for a memory game i almost have it right by i can get it to print out the box correctly.

i have a Java code for a memory game i almost have it right by i can get it to print out the box correctly.

this is the code i have

public String toString() { StringBuffer board = new StringBuffer(); // Append column number board.append(" "); for (int i = 1; i <= BOARD_SIZE; i++) board.append(i + " "); board.append(" "); // Append separator board.append(" ="); for (int i = 1; i <= BOARD_SIZE; i++) board.append("=="); board.append(" "); for (int i = 1; i <= BOARD_SIZE; i++) { board.append("| "); for (int j = 1; j <= BOARD_SIZE; j++) { board.append(gameBoard[i][j] + " "); } board.append("| "); }

and it prints this

1 2 3 4 ========= | * * * * | | * * * * | | * * * * | | * * * * | =========

but i need it like this

1 2 3 4 ========= 1| * * * * | 2| * * * * | 3| * * * * | 4| * * * * | =========

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!