public class TestRect {
  static void testArea(Rectangle r, int h, int w) throws Exception {
    r.setHeight(h);
    r.setWidth(w);
    if (r.area() != h * w) {
      throw new Exception("Inconsistent geometry!");
    }
  }
  public static void main(String args[]) throws Exception {
    testArea(new Rectangle(50, 50, 10, 20), 20, 40);
    testArea(new Square(50, 50, 20), 20, 40);
  }
}
