Source of ShapeBase.java


  1: //ShapeBase.java

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

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

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

 37:     public int getOffset( )
 38:     {
 39:         return offset;
 40:     }
 41: }