shape4: Rect.java

/*
 * Definition of class Rect
 */

class Rect { //*1 Class definition

	public int x, y, wid, ht; //*2 Instance variables

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

	public float area() { //*3
		return (float) (wid * ht);
	}
}
[download file]