Define an abstract class Shape with concrete subclasses Circle, Square, Rectangle such that every class that inherits from Shape must redefine the following methods:
public double sizeOf() that returns some sensible parameter indicating the size of the object.
public boolean equals(Object o) based on the defining characteristics of the object rather than on pointer equality.
public String toString() to print out the defining characteristics of the object.
Consider the following interface:
public interface Sortable { public int cmp(Sortable s); // return -1 if this < s, // 0 if this = s, // 1 if this > s }
Java allows an interface definition to include concrete "default" methods. (Look up the documentation for Java.) Add a default method to the class Sortable that sorts arrays of type Sortable[] (use any sorting algorithm of your choice).
Extend the definition of Shape so that all objects that inherit from Shape are Sortable, and update the definitions of Circle, Square and Rectangle accordingly.
Submit two zip files, ABCYYYYNN-Task1.zip and ABCYYYYNN-Task2.zip, where ABCYYYYNN is your roll number. Each zip file should contain all Java source files for the corresponding task.
Submissions that do not follow this naming convention will not be graded.
Submissions with compilation errors will not be graded.