Rectangle
- w, h: int
+ setWidth(w)
+ setHeight(h)
+ area()
Square
+ setWidth(w) ⚠
+ setHeight(h) ⚠
Square breaks the contract
1class Rectangle {2 void setWidth(int w){ this.w = w; }3 void setHeight(int h){ this.h = h; }4 int area(){ return w * h; }5}6class Square extends Rectangle {7 void setWidth(int w){ this.w = w; this.h = w; } // ⚠ also sets height8}