The Graph Class IV

 [Previous Chapter]  [Previous Page]  [Contents]  [Next Page]  [Next Chapter]

Graph.java
/**
 * Return the canvas as one string
 *
 * @return      string representation of the canvas.
 */
public String toString() {
   String s = "";
   for (int row = 0; row < rows; ++row) {
      for (int column = 0; column < columns; ++column) {
         s += canvas[row][column];
      }
      s += "\n";
   }
   return s;
}

*This could be improved by avoiding the inclusion of spaces that are followed by a line terminator only. Any volunteers?
 

 [Previous Chapter]  [Previous Page]  [Contents]  [Next Page]  [Next Chapter]
Copyright © 2001, 2002 Andreas Borchert, converted to HTML on February 11, 2002