document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /*
  2. Program 8.6 (Time2Test)
  3. @author (srachmadbudi)
  4. @version (1.0)
  5.  */
  6.  
  7. public class Time2Test{
  8.     public static void main(String[] args){
  9.         Time2 t1 = new Time2();
  10.         Time2 t2 = new Time2(2);
  11.         Time2 t3 = new Time2(21,34);
  12.         Time2 t4 = new Time2(12,25,42);
  13.         Time2 t5 = new Time2(t4);
  14.  
  15.         System.out.println("Constructed with:");
  16.         System.out.println("t1: all arguments defaulted");
  17.         System.out.printf(" %s\\n", t1.toUniversalString());
  18.         System.out.printf(" %s\\n", t1.toString());
  19.  
  20.         System.out.println("t2: hour specified; minute and second defaulted");
  21.         System.out.printf(" %s\\n", t2.toUniversalString());
  22.         System.out.printf(" %s\\n", t2.toString());
  23.  
  24.         System.out.println("t3: hour and minute specified; second defaulted");
  25.         System.out.printf(" %s\\n", t3.toUniversalString());
  26.         System.out.printf(" %s\\n", t3.toString());
  27.  
  28.         System.out.println("t4: hour, minute, and second specified");
  29.         System.out.printf(" %s\\n", t4.toUniversalString());
  30.         System.out.printf(" %s\\n", t4.toString());
  31.  
  32.         System.out.println("t5: Time2 object t4 specified");
  33.         System.out.printf(" %s\\n", t5.toUniversalString());
  34.         System.out.printf(" %s\\n", t5.toString());
  35.        
  36.         //coba inisialisasi t6 dengan nilai invalid
  37.         try{
  38.             Time2 t6 = new Time2(27,74,99);
  39.         }catch(IllegalArgumentException e){
  40.             System.out.printf("\\nException while initializing t6: %s\\n",
  41.                     e.getMessage());
  42.         }
  43.     }
  44. }
');