Due Date:
Friday, 5 March 2021
File(s) to be submitted:
FigureInfo.java, Measurable.java, Circle.java, Oval.java, Rectangle.java, Triangle.java
Sample Output:
SampleOutput.html
Starter Files:
Summary
Revise the Measurable interface so that it extends Comparable<Measurable>.Note that once you make this change, the Shape classes will all have errors in them -- they don't implement theRevise the shape classes so that they actually implement thecompareTo(Measurable)
method. Theimplements Measurable
clause now includes a promise to implement that method.compareTo(Measurable)
method.Note that by making Measurable extend Comparable<Measurable>, the promise to be Measurable implies a promise to be Comparable<Measurable>, so you don't need to promise that again.Revise the program FigureInfo so that it reads in three objects of each shape, storing all twelve of the shapes in a single array, then sorts that array and prints it out in a nice table. (Right now it reads in a single instance of each shape and prints out those four shapes in a table -- not sorted.)Also, you shouldn't change the shape classes from implementing
Measurable
.
There's not much more to say than I said above.
Note 1: The version of Rectangle in the sample programs is sorted by width and then height. Your version will be similar, but not the same.Note 2: There's an even better way to do this task when all the implementing classes do things the same way, but that'd take us into abstract classes, which are a bit more advanced than I want to get into. DO NOT use abstract classes for this assignment.