shape6 (Tester.java is same as before): Rect.java

/*
 * 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);
	}
}
[download file]