You are developing a simple graphics

  

You are developing a simple graphics package that will allow you to draw and manipulate simple geometric shapes such as squares, rectangles, etc. Your initial design is along the following lines:
 

public class Rectangle {
private int h, w;
public intgetHeight() {…}
public intsetHeight(int x) {…}

}
 

public class Square extends Rectangle {
// ???
}
This question has a ‘devil’s advocate’ nature to it and is in two parts.
 

You intend to model a square as inheriting from a rectangle. How would you complete the code on the above right to realize this intention?

Tags: No tags