Write an abstract class Shape
that has a concrete variable sides
, a concrete method .getSides()
and an abstract method .getArea()
. Then write two classes, Rectangle
and Circle
, that extend Shape. (For the purposes of this assignment, a Circle has 0 sides, although you may wish to research other possible answers to that question.)
Write a main program ShapeTester
that demonstrates the use of these two shapes.
Modify the abstract class Shape
so that it also has an abstract method .equals()
. This method returns true if two different Shape
objects have identical dimensions.
Note that the .equals()
method is part of the Object
superclass. In overriding it, you'll need to use an Object parameter for the "other" object, and then cast it into the class implementing the method (in this case, the Rectangle or Circle shape).
Modify the main program ShapeTester
to demonstrates the use of all the methods of the Shape class.