Question: //create an abstract Shape class abstract class Shape { static int shapeCount = 0; public Shape() { //shapeCount is incremented every time a new shape

 //create an abstract Shape class abstract class Shape { static int

//create an abstract Shape class abstract class Shape { static int shapeCount = 0; public Shape() { //shapeCount is incremented every time a new shape is created shapeCount = shapeCount + 1; } //define abstract methods area(), perimeter(), and getShape() abstract double area(); abstract double perimeter(); //getShape() will return a String that represents a particular shape abstract String getShape(); }

Comparable (3 points) 1. Java has a built-in interface called Comparable. It only has one method, compareTo (). The T in Comparable is a generic type. When you implement the interface, you replace T with the type that you want to compare to compareTo () returns an integer. For two objects x and y, x.compare To (y) should be negative if xy and zero if x=y. 2. Modify Shape so that it implements Comparable. Notice that we can implement multiple interfaces, but we can only extend one class. For the purpose of this assignment, we will consider one shape to be bigger than another if its area is bigger. In the main method of Shape Tester, sort the array you have created using the Collections.sort() method. Since Shape implements Comparable, the Collections.sort() method will know how it should compare two shapes. It will use this to sort the shapes by their area. Display the elements of this array again to make sure the sorting worked properly

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!