shape6 (other files are same as before)

Rect.java  [download]

/*
 * Definition of class Rect
 */

class Rect {

	private int x, y, wid, ht;

	public Rect (int xin, int yin, int widin, int htin) {
		x = xin; y = yin;
		wid = widin; ht = htin;
	}

	public void setPos (int xin, int yin) { //*1 Use setter instead of direct access
		x = xin; y = yin; //*1
	}

	public void setSize (int widin, int htin) { //*1
		wid = widin; ht = htin; //*1
	}

	public void draw() {
		System.out.println ("Drawing rectangle at " 
			+ x + ", " + y + ", " + wid + ", " + ht);
	}

	public float area() {
		return (float) (wid * ht);
	}
}

Circle.java  [download]

/*
 * Definition of class Circle
 */

class Circle {

	private int x, y, rad;

	public Circle (int xin, int yin, int radin) {
		x = xin; y = yin;
		rad = radin;
	}

	public void setPos (int xin, int yin) { //*1 Use setter instead of direct access
		x = xin; y = yin; //*1
	}

	public void setSize (int radin) { //*1
		rad = radin; //*1
	}

	public void draw() {
		System.out.println ("Drawing circle at " + x + ", " + y
			+ ", radius = " + rad);
	}

	public float area() {
		return (float) (rad * rad * 3.14159);
	}
}