MCPcopy Create free account
hub / github.com/MolinDeng/Princeton-algs4 / toString

Method toString

LabEnv/09Lab/BoggleBoard.java:181–192  ·  view source on GitHub ↗

Returns a string representation of the board, replacing 'Q' with "Qu". @return a string representation of the board, replacing 'Q' with "Qu"

()

Source from the content-addressed store, hash-verified

179 * @return a string representation of the board, replacing 'Q' with "Qu"
180 */
181 public String toString() {
182 StringBuilder sb = new StringBuilder(m + " " + n + "\n");
183 for (int i = 0; i < m; i++) {
184 for (int j = 0; j < n; j++) {
185 sb.append(board[i][j]);
186 if (board[i][j] == 'Q') sb.append("u ");
187 else sb.append(" ");
188 }
189 sb.append("\n");
190 }
191 return sb.toString().trim();
192 }
193
194 /**
195 * Unit tests the BoggleBoard data type.

Callers 2

getCurrentPathMethod · 0.45
dfsMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected