Guest User

Untitled

a guest
Aug 10th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. import java.util.Comparator;
  2.  
  3. public class GeometricObjectAreaComparator
  4. implements Comparator<GeometricObject>
  5. {
  6. // Return 1 of o1 area > o2 area
  7. // Return -1 of o1 area < o2 area
  8. // Return 0 of o1 area == o2 area
  9. public int compare(GeometricObject o1, GeometricObject o2)
  10. {
  11. // fill in your code
  12. if (o1.getArea() > o2.getArea())
  13. {
  14. return 1;
  15. }
  16. else if (o1.getArea() < o2.getArea())
  17. {
  18. return -1;
  19. }
  20. else
  21. {
  22. return 0;
  23. }
  24. }
  25. }
Add Comment
Please, Sign In to add comment