/*
* Definition of subclass Rect
*/
class Rect extends Shape {
private int wid; //*1 Change internal representation
private float aspect; //*1
public Rect (int xin, int yin, int widin, int htin) { //*2 But not public API
x = xin; y = yin;
// convert from given inputs to our internal data
wid = widin;
aspect = (float)widin/htin; //*3 Convert from API to internal
}
public void setSize (int widin, int htin) { //*2
wid = widin; //*3
aspect = (float)widin/htin; //*3
}
public void draw() {
System.out.println ("Drawing rectangle at "
+ x + ", " + y + ", " + wid + ", " + wid/aspect); //*3
}
public float area() {
return (float) (wid * wid / aspect); //*3
}
}