Source of ShapeBase.java


  2: /**
  3:  Abstract base class for drawing simple shapes on the screen
  4:  using keyboard characters. 
  5: */
  6: public abstract class ShapeBase implements ShapeInterface
  7: {
  8:     private int offset; 
  9:     
 10:     public ShapeBase( )
 11:     {
 12:         offset = 0;
 13:     }

 15:     public ShapeBase(int theOffset)
 16:     {
 17:         offset = theOffset;
 18:     }

 20:     /**
 21:      Draws the shape at the current line.
 22:     */
 23:     public abstract void drawHere( );
 24:               
 25:     /**
 26:      Draws the shape at lineNumber lines down
 27:      from the current line.
 28:     */
 29:     public void drawAt(int lineNumber)
 30:     {
 31:         for (int count = 0; count < lineNumber; count++)
 32:             System.out.println( ); 
 33:         drawHere( );
 34:     } 
 35:     
 36:     public void setOffset(int newOffset)
 37:     {
 38:         offset = newOffset;
 39:     }

 41:     public int getOffset( )
 42:     {
 43:         return offset;
 44:     }
 45: }