// DrawingWorld.java


/* 
;   ;;;;;  ;           ;          
;   ;    ; ;           ;          
;   ;    ; ;           ;          
;   ;   ;  ;    ;;;    ; ;;       
;   ;;;;   ;   ;   ;   ;;  ;      
;   ;   ;  ;  ;     ;  ;    ;     
;   ;    ; ;  ;     ;  ;    ;     
;   ;    ; ;  ;     ;  ;    ;     
;   ;    ; ;   ;   ;   ;;  ;      
;   ;;;;;  ;    ;;;    ; ;;       
;                                 
;                                 
;                                 
*/
// to represent a blob on the canvas
class Blob {
  Posn center;
  int radius;

  Blob(Posn center, int radius) {
    this.center = center;
    this.radius = radius;
  }

  // draw this blob in the given World
  boolean draw(World w) {
  	System.out.println("Drawing a blob with radius " + this.radius);
    return w.drawDisk(this.center, this.radius, new Red()) &&
	      w.drawAll();
  } 

  // produce a blob with the center moved by the given distance;
  Blob move(int dx, int dy){
    return new Blob(new Posn(this.center.x + dx, 
                               this.center.y + dy),
                      this.radius);
  }

  // determine whether this blob is the same as than given blob
  boolean same(Blob b){
    return this.center.x == b.center.x
        && this.center.y == b.center.y
        && this.radius == b.radius;
  }
  
  // run the tests and start the world
  public static void main(String[] argv){

    // Examples of blobs: c1, c2, c3 ----------------------------------
    Blob b1 = new Blob(new Posn(100, 300), 30);  // center low
    Blob b2 = new Blob(new Posn(180, 20), 20);   // top right corner
    Blob b3 = new Blob(new Posn(40, 360), 40);   // bottom left corner


    // Building the drawing world ---------------------

    // Drawing the circles:" --------------------------------------
    // make a big blob and a small blob
    Blob bigBlob = new Blob(new Posn(100, 200), 50);
    Blob smallBlob = new Blob(new Posn(100, 100), 25);
    Blob movedcircle = b1.move(50, 50);
    
  	
  	System.out.println(  	
  	 // Testing the same method in the class Circle --------------------
  	"Tests: \n" +
  	"test same(): " + 
		(b1.same(new Blob(new Posn(100, 300), 30))) + "\n" +
	"test same(): " + 
    		(b1.same(new Blob(new Posn(100, 300), 50)) == false) + "\n" +
  	"test same(): " + 
    		(b1.same(new Blob(new Posn(130, 300), 30)) == false) + "\n" +
  	"test same(): " + 
   		(b1.same(new Blob(new Posn(100, 140), 30)) == false) + "\n" +
    
   	"test move(): " + 
		(b1.move(50, 50).same(new Blob(new Posn(150, 350), 30))) + "\n" +
	"test move(): " + 
		(b2.move(-20, 20).same(new Blob(new Posn(160, 40), 20))) + "\n"
  	);

    // make an example of a drawing world
    World dw = new World();

    // show the world as a canvas of the size 200, 400
    boolean testWorld = dw.start(200, 400);
    
    System.out.println(
    	  	"Draw a blob in the center: " + 
    	  		(b1.draw(dw)) + "\n" +  // ---- draw a blob in the center 
    	  	
    	  	"Draw a blob in the top right: " + 
    	  		(b2.draw(dw)) + "\n" +  // ---- draw a blob in the top right

    	  	"Draw a blob in the bottom left: " + 	
    	  		(b3.draw(dw)) + "\n" // ---- draw a blob in the bottom left
    	  	);
  }
  

}




