/**
 * Sierpinsky.java
 * @author Frank Ruskey, January 1998.
 * @version 1.0
 * @revised Johannes Martin
 * @version 1.1
 * @revised Bette Bultena October 2001.
 * @version 1.2
 */

/** 
 * This class defines Sierpinski curves.  
 */
public abstract class Sierpinski {
   /**
    * Produce the <i>i</i>-th Sierpinski curve
    */
   public void makeCurve( int i ) {
      A( i );  plot( 1, 1 );
      B( i );  plot( -1, 1 );
      C( i );  plot( -1, -1 );
      // something is missing here?
   }
  
   private void A ( int i ) {
      if (i>0) {
         A( i-1 );  plot( 1, 1 );		
         B( i-1 );  plot( 2,  0 );		
         D( i-1 );  plot( 1, -1 );		
         A( i-1 );  
      } 
   }
  
   private void B ( int i ) {
      if (i>0) {
         B( i-1 );  plot( -1, 1 );		
         C( i-1 );  plot(  0, 2 );		
         A( i-1 );  plot( 1, 1 );		
         B( i-1 );  
       } 
   }
  
   private void C ( int i ) {
      if (i>0) {
         /* Fill in the missing code!   */
      } 
   }

   private void D ( int i ) {
      if (i>0) {
         /* Fill in the missing code!  */
      }
   }

   protected abstract void plot ( int xh, int yh );
	
}

