/*
* Now, let's change implementation of circle
* to use bounding box, starting at top left
*
* Note that Tester.java doesn't change at all
*/
class Circle extends Shape {
private int width, height; //*1 Change internal representation
public Circle (int x, int y, int rad) { //*2 But not public API
this.x = x - rad; //*3 Convert from API to internal
this.y = y - rad; //*3
width = 2 * rad; //*3
height = 2 * rad; //*3
}
public void setSize (int rad) { //*2
width = 2 * rad; //*3
height = 2 * rad; //*3
}
public void draw() {
System.out.println ("Drawing circle at "
+ (x + width/2) + ", " + (y + height/2) //*3
+ ", radius = " + width/2); //*3
}
public float area() {
return (float) ((width/2) * (width/2) * 3.14159); //*3
}
}