Question: Comparable Interface Problem 1.3 1. Create a Square class, as a child GeometricObject, which has an integer side variable (GeometricObject.java is in the textbook files

 Comparable Interface Problem 1.3 1. Create a Square class, as a

Comparable Interface Problem 1.3 1. Create a Square class, as a child GeometricObject, which has an integer side variable (GeometricObject.java is in the textbook files on Blackboard.) 2. Provide a constructor that allows side to be set 3. Create a getArea() method that returns the area of the square 4. Override toString() to print a string representation of a square object 5. Have Square class implement Comparable 6. Implement a compareTo() method for the Square class 7. Make a main() method 8. Inside main(), make an array of a hundred random Square objects 9. Call Arrays.sort() on the array 10. Print the array Problem 1.4 1. Create a Name class that has a string instance variable called first and a string instance variable called last 2. Provide a constructor that allows first and last to be set 3. Provide public getters for both instance variables 4. Override toString() to print a string representation of a Name object 5. Have Name class implement comparable 6. Implement compareTo() to compare by first name and then the last name 7. Make a main() method 8. Inside main(), make an array of several Name objects 9. Call Arrays.sort() on the array 10. Print the array

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!