Guest User

Untitled

a guest
Dec 18th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. private TimeInterval StartTime,EndTime;
  2.  
  3. public TimeInterval(Time time,Time time2){
  4. StartTime = (TimeInterval) time; //cannot convert from Time to TimeInterval
  5. EndTime = (TimeInterval) time2; //cannot convert from Time to TimeInterval
  6. }
  7.  
  8. @Override
  9. public int compareTo(TimeInterval that) {
  10.  
  11. if (StartTime.compareTo(that.EndTime) > 0) {
  12. return 1;
  13. }
  14. if (EndTime.compareTo(that.StartTime) < 0) {
  15. return -1;
  16. }
  17. return 0;
  18. }
  19.  
  20. private Time StartTime,EndTime;
  21.  
  22. public TimeInterval(Time time,Time time2){
  23. StartTime = time;
  24. EndTime = time2;
  25. }
  26.  
  27. @Override
  28. public int compareTo(TimeInterval that) {
  29.  
  30. if (((TimeInterval)StartTime).compareTo((TimeInterval)that.EndTime) > 0) {
  31. return 1;
  32. }
  33. if (((TimeInterval)EndTime).compareTo((TimeInterval)that.StartTime) < 0) {
  34. return -1;
  35. }
  36. return 0;
  37. }
Add Comment
Please, Sign In to add comment