getCharacter method

String getCharacter(
  1. int x,
  2. int y
)

Gets the character at (x, y). Returns a space if coordinates are out of bounds.

Implementation

String getCharacter(int x, int y) {
  if (!isCellValid(x, y)) return ' ';
  return characters[y * width + x];
}