Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Comparator;
- public class GeometricObjectAreaComparator
- implements Comparator<GeometricObject>
- {
- // Return 1 of o1 area > o2 area
- // Return -1 of o1 area < o2 area
- // Return 0 of o1 area == o2 area
- public int compare(GeometricObject o1, GeometricObject o2)
- {
- // fill in your code
- if (o1.getArea() > o2.getArea())
- {
- return 1;
- }
- else if (o1.getArea() < o2.getArea())
- {
- return -1;
- }
- else
- {
- return 0;
- }
- }
- }
Add Comment
Please, Sign In to add comment