The Graph Class

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

Graph.java
public class Graph {

   private char[][] canvas; // used to draw our graphs
   private int rows;        // number of rows in canvas
   private int columns;     // number of columns in canvas
   private char pen;        // currently used for drawing
   private double x0;       // current x range is [x0 .. x1)
   private double x1;
   private double y0;       // current y range is [y0 .. y1)
   private double y1;

   /**
    * Prepare a graph for the given canvas.
    *
    * @graphCanvas two-dimensional array, already allocated.
    */
   public Graph(char[][] graphCanvas) {
      canvas = graphCanvas;
      rows = canvas.length;
      columns = canvas[0].length;
      x0 = 0; x1 = 1;
      y0 = 0; y1 = 1;
      pen = '*';
   }

   // ...

}

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