Question: Java Programming Customize any of the programs in Listings 13.7, 13.9 or 13.10, and create your own solution. For example, one of the programs was

Java Programming

Customize any of the programs in Listings 13.7, 13.9 or 13.10, and create your own solution. For example, one of the programs was to sort Rectangles. You could customize it to sort Triangles, or Circle.Make sure include the changes that you had made in your program purpose.

Listings:

13.7 TestEdible.java

Java Programming Customize any of the programs in Listings 13.7, 13.9 or

13.9 ComparableRectangle.java

1 public class ComparableRectangle extends Rectangle 2 implements Comparable { 3 /** Construct a ComparableRectangle with specified properties */ 4 public ComparableRectangle(double width, double height) { 5 super(width, height); 6 } 7 8 @Override // Implement the compareTo method defined in Comparable 9 public int compareTo(ComparableRectangle o) { 10 if (getArea() > o.getArea()) 11 return 1; 12 else if (getArea()

13.10 SortRectangles.java

1 public class SortRectangles { 2 public static void main(String[] args) { 3 ComparableRectangle[] rectangles = { 4 new ComparableRectangle(3.4, 5.4), 5 new ComparableRectangle(13.24, 55.4), 6 new ComparableRectangle(7.4, 35.4), 7 new ComparableRectangle(1.4, 25.4)}; 8 java.util.Arrays.sort(rectangles); 9 for (Rectangle rectangle: rectangles) { 10 System.out.print(rectangle + " "); 11 System.out.println(); 12 } 13 } 14 }

1 public class TestEdible { 2 public static void main(String[] args) 3 Object[] objects {new Tiger(), new Chicken(), new Apple()); 4 for (int i = 0; i

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!