DETAILS You will create 3 shape classes Circle Rectangle Tri
DETAILS You will create 3 shape classes (Circle, Rectangle, Triangle) that all inherit from a single abstract class called AbstractShape which implements Shape (also created by you). You are also responsible for creating the driver class \"Assignment7.java\" (program that tests your classes and described on page 3) which does the following reads input data from a file instantiates various objects of the three shapes based on the input data stores each in a LinkedList outputs this list to an output file sorts a \"copy\" of this LinkedList of objects outputs the sorted version of the list to the output file outputs the original list to the output file This driver program also needs to \"ignore errors in the input file that breach the specified input format as described in the Assianment7,java details (see page 3 1. Shape.java This is an interface that has 2 abstract methods, and passes the responsibility of implementing the compareTo method to the class that implements Shape (you may note, nomally Comparable is \"implemented\" by a class. However, an interface cannot implement because interfaces can only contain abstract methods. That said, an interface can only extend other interfaces and the responsibility of actually \"implementing\" the abstract method(s) of the super class interface is passed on to the sub-classes) public interface Shape extends Comparable public double calculateAreal) Il This abstract method is implemented at the concrete level public Shape copyShape); Il also implemented at the concrete level 2. AbstractShape.java public abstract class AbstractShape implements Shape This class should contain an instance field to store the name of each obiect. The constructor which sets this field should receive the name and a number to be concatenated to the name and then stored in the name field Recall, when the super class has a parameterized constructor, the sub-classes will need to call it AND the sub- classes will need to also provide a constructor without parameters This abstract class will implement the compareTo method passed on from the Shape interface and will pass on the responsibility of implementing calculateArea to the extending sub-classes (compare To will use the calculateArea method when comparing 2 Shape objects). Along with compare To, one more concrete method should be included. The following will be used by the sub-classes\' toString method: public String getName) II Simply returns the name field data
Solution
lass OverloadDemo { void area(float x) { System.out.println(\"the area of the square is \"+Math.pow(x, 2)+\" sq units\"); } void area(float x, float y) { System.out.println(\"the area of the rectangle is \"+x*y+\" sq units\"); } void area(double x) { double z = 3.14 * x * x; System.out.println(\"the area of the circle is \"+z+\" sq units\"); } } class Overload { public static void main(String args[]) { OverloadDemo ob = new OverloadDemo(); ob.area(5); ob.area(11,12); ob.area(2.5); } }