Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. package aufg_74;
  2.  
  3. public class TimeChecker {
  4. public static void showTimeInMinutesFormat(Time a){
  5. System.out.print(a.timeInMinutesFromZero());
  6. }
  7.  
  8. public static void showTimeInMinutesFormatLn(Time a){
  9. System.out.println(a.timeInMinutesFromZero());
  10. }
  11.  
  12. public static void showTimeOnConsole(Time a){
  13. if((a.getMinutes()) >= 10){
  14. if(a.getHour()>= 10){
  15. System.out.print(a.getHour() + ":" + a.getMinutes() + " ");
  16. }
  17. else{
  18. System.out.print("0" + a.getHour() + ":" + a.getMinutes() + " ");
  19. }
  20. }
  21. else {
  22. if(a.getHour()>= 10){
  23. System.out.print(a.getHour() + ":0" + a.getMinutes() + " ");
  24. }
  25. else{
  26. System.out.print("0" + a.getHour() + ":0" + a.getMinutes() + " ");
  27. }
  28. }
  29.  
  30. }
  31.  
  32. public static void showTimeOnConsoleLn(Time a){
  33. showTimeOnConsole(a);
  34. System.out.println();
  35. }
  36.  
  37. public static void main(String[] args) {
  38.  
  39. Time z = new Time(8,50);
  40. System.out.print("z: ");
  41. showTimeOnConsole(z);
  42. System.out.print(" In minutes from 0:00: ");
  43. showTimeInMinutesFormatLn(z);
  44.  
  45.  
  46. Time u = new Time(9,00);
  47. System.out.print("u: ");
  48. showTimeOnConsole(u);
  49. System.out.print(" In minutes from 0:00: ");
  50. showTimeInMinutesFormatLn(u);
  51.  
  52. Time x = new Time(9,10);
  53. System.out.print("x: ");
  54. showTimeOnConsole(x);
  55. System.out.print(" In minutes from 0:00: ");
  56. showTimeInMinutesFormatLn(x);
  57.  
  58.  
  59. Time y = new Time(18,5);
  60. System.out.print("y: ");
  61. showTimeOnConsole(y);
  62. System.out.print(" In minutes from 0:00: ");
  63. showTimeInMinutesFormatLn(y);
  64.  
  65.  
  66. Time t = new Time(9,10);
  67. System.out.print("t: ");
  68. showTimeOnConsole(t);
  69. System.out.print(" In minutes from 0:00: ");
  70. showTimeInMinutesFormatLn(t);
  71.  
  72. System.out.println();
  73.  
  74.  
  75. System.out.print("z is later than u: ");
  76. System.out.println(z.isLaterThan(u));
  77.  
  78. System.out.print("x is later than y: ");
  79. System.out.println(x.isLaterThan(y));
  80.  
  81. System.out.print("y is later than x: ");
  82. System.out.println(y.isLaterThan(x));
  83.  
  84. System.out.println();
  85.  
  86. System.out.print("t is the same time as x: ");
  87. System.out.println(t.isSameTimeAs(x));
  88.  
  89. System.out.print("y is the same time as x: ");
  90. System.out.println(y.isSameTimeAs(x));
  91.  
  92. System.out.println();
  93.  
  94. System.out.println("y is "+ y.distanceInMinTo(x) + " minutes away from x.");
  95.  
  96. System.out.println("x is "+ x.distanceInMinTo(u) + " minutes away from u.");
  97.  
  98. System.out.println("u is "+ u.distanceInMinTo(x) + " minutes away from x.");
  99.  
  100. System.out.println();
  101.  
  102. showTimeOnConsoleLn(x.timeInTimeFormat(150));
  103.  
  104. System.out.println();
  105.  
  106. showTimeOnConsole(x.timeInTimeFormat(x.timeInMinutesFromZero()));
  107. System.out.print(" plus 10 minutes ");
  108. showTimeOnConsoleLn(x.addDuration(10));
  109.  
  110.  
  111.  
  112.  
  113.  
  114. }
  115.  
  116.  
  117.  
  118.  
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement