Advertisement
Dr_U

Time2test

Oct 14th, 2020 (edited)
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.40 KB | None | 0 0
  1.  
  2. public class Time2Test
  3. {
  4.    
  5.     public static void main(String [] args)
  6.     {
  7.        Time2 t1 = new Time2();          //00:00:00
  8.        Time2 t2 = new Time2(2);         //02:00:00
  9.        Time2 t3 = new Time2(21,34);     //21:34:00
  10.        Time2 t4 = new Time2(12,25,42);  //12:25:42
  11.        Time2 t5 = new Time2(t4);        //12:25:42
  12.        
  13.        System.out.println("Construted with : ");
  14.        System.out.printf("t1: all arguments defaulted\n");
  15.        System.out.printf("    %s\n",t1.toUniversalString());
  16.        System.out.printf("    %s\n",t1.toString());
  17.              
  18.        System.out.printf("t2: hour specified; minute and second defaulted\n");
  19.        System.out.printf("    %s\n",t2.toUniversalString());
  20.        System.out.printf("    %s\n",t2.toString());      
  21.      
  22.        System.out.printf("t3: hour and minute specified\n");
  23.        System.out.printf("    %s\n",t3.toUniversalString());
  24.        System.out.printf("    %s\n",t3.toString());
  25.          
  26.        System.out.printf("t4: hour, minute and second specified; minute and second defaulted\n");
  27.        System.out.printf("    %s\n",t4.toUniversalString());
  28.        System.out.printf("    %s\n",t4.toString());
  29.        
  30.        System.out.printf("t5: Time2 object t4 specified; minute and second defaulted\n");
  31.        System.out.printf("    %s\n",t5.toUniversalString());
  32.        System.out.printf("    %s\n",t5.toString());
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement