We want to add a new branch to the hierarchy to draw ellipses and circles. Obviously, the relationship between ellipses and circles is analogous to that of rectangles and squares. In fact, this analogy is emphasized by the Graphics library tools used to draw ellipses:
public void fillOval(x, y, wid, ht)This method draws the filled oval inscribed in the rectangle defined by x, y, wid, and ht (note: it does not draw the rectangle):
First copy your Exercise1 folder to your Exercise2 folder. Then write Ellipse.java, and Circle.java as a child class of Ellipse. The constructors for Ellipse and Circles are analogous to their counterparts in Rect and Square, respectively:
public Rect(int x, int y, int wid, int ht, Color col) public Square(int x, int y, int wid, Color col)
Finally, write BasicShapesDemo2.java to display all 4 shapes.