# cs java Solution

Code –UMLprovided

(Problem is on page593 at the end of Chapter 15)

Instructions: Programs are due by midnight on the due date by email. Please follow the Homework Submission Instructions for full credit.Please remember to properly indent your code and include appropriate comments. Follow instructions given for each problem in the textbook.

Required

(50 points) 15.7EnableGeometricObject comparable

Modify the GeometricObject class to implement the Comparable interface, and define a static max method in the GeometricObject class for finding the larger of two GeometricObject objects. Use the provied UML diagram and implement the new GeometricObject1, Circle1, and Rectangel1 classes. Write a test program that uses the max method to find the larger of two circles and the larger of two rectangles.

Sample main provided.

*Hint create a new GeometricObject class called GeometricObject1 which will implement Comparable.

abstract class GeometricObject1 implements Comparable

GeommetricObject1 will need to have a compareTo method and the method

public static GeometricObject1 max(GeometricObject1 o1,GeometricObject1 o2) {

which will use the compareTo method to return the relationship between o1 and o2, the value, 0,1, or -1.

You will also need a class Circle1 that extends GeometricObject1.

class Circle1 extends GeometricObject1 {

You will also need a class Rectangle1 that extends GeometricObject1.

classRectangle1 extends GeometricObject1 {

Classes GeometricObject, Circle and Rectangle have been provided for you as a starting point.

(Problem is on page593 at the end of Chapter 15)

Instructions: Programs are due by midnight on the due date by email. Please follow the Homework Submission Instructions for full credit.Please remember to properly indent your code and include appropriate comments. Follow instructions given for each problem in the textbook.

Required

(50 points) 15.7EnableGeometricObject comparable

Modify the GeometricObject class to implement the Comparable interface, and define a static max method in the GeometricObject class for finding the larger of two GeometricObject objects. Use the provied UML diagram and implement the new GeometricObject1, Circle1, and Rectangel1 classes. Write a test program that uses the max method to find the larger of two circles and the larger of two rectangles.

Sample main provided.

*Hint create a new GeometricObject class called GeometricObject1 which will implement Comparable.

abstract class GeometricObject1 implements Comparable

GeommetricObject1 will need to have a compareTo method and the method

public static GeometricObject1 max(GeometricObject1 o1,GeometricObject1 o2) {

which will use the compareTo method to return the relationship between o1 and o2, the value, 0,1, or -1.

You will also need a class Circle1 that extends GeometricObject1.

class Circle1 extends GeometricObject1 {

You will also need a class Rectangle1 that extends GeometricObject1.

classRectangle1 extends GeometricObject1 {

Classes GeometricObject, Circle and Rectangle have been provided for you as a starting point.

You'll get 1 file (2.2KB)