document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1.  
  2.  
  3. import static org.junit.Assert.*;
  4. import org.junit.After;
  5. import org.junit.Before;
  6. import org.junit.Test;
  7.  
  8. /**
  9. * The test class Time2Test.
  10. *
  11. * @author Zelda Elma Sibuea
  12. * @version 12/10/2020
  13. */
  14. public class Time2Test
  15. {
  16. public static void main(String[] args)
  17. {
  18. Time2 t1 = new Time2(); // 00:00:00
  19. Time2 t2 = new Time2(2); // 02:00:00
  20. Time2 t3 = new Time2(21, 34); // 21:34:00
  21. Time2 t4 = new Time2(12, 25, 42); // 12:25:42
  22. Time2 t5 = new Time2(t4); // 12:25:42
  23.  
  24. System.out.println("Constructed with:");
  25. displayTime("t1: all default arguments",t1);
  26. displayTime("t2: hour specified; default minute and second",t2);
  27. displayTime("t3: hour and minute specified; default second",t3);
  28. displayTime("t4: hour, minute and second specified",t4);
  29. displayTime("t5: Time2 object t4 specified",t5);
  30.  
  31. //inisialisasi dengan nilai yang tidak valid
  32. try
  33. {
  34. Time2 t6 = new Time2(27, 74, 99);
  35. }
  36. catch (IllegalArgumentException e)
  37. {
  38. System.out.printf("%nException while initializing t6: %s%n",
  39. e.getMessage());
  40. }
  41. }
  42.  
  43.  
  44. private static void displayTime(String header, Time2 t)
  45. {
  46. System.out.printf("%s%n %s%n %s%n",
  47. header, t.toUniversalString(), t.toString());
  48. }
  49. }
  50.  
  51.  
');