1 | // Fig. 8.6: Time2Test.java |
---|
2 | // Overloaded constructors used to initialize Time2 objects. |
---|
3 | |
---|
4 | public class Time2Test |
---|
5 | { |
---|
6 | public static void main( String args[] ) |
---|
7 | { |
---|
8 | Time2 t1 = new Time2(); // 00:00:00 |
---|
9 | Time2 t2 = new Time2( 2 ); // 02:00:00 |
---|
10 | Time2 t3 = new Time2( 21, 34 ); // 21:34:00 |
---|
11 | Time2 t4 = new Time2( 12, 25, 42 ); // 12:25:42 |
---|
12 | Time2 t5 = new Time2( 27, 74, 99 ); // 00:00:00 |
---|
13 | Time2 t6 = new Time2( t4 ); // 12:25:42 |
---|
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( |
---|
21 | "t2: hour specified; minute and second defaulted" ); |
---|
22 | System.out.printf( " %s\n", t2.toUniversalString() ); |
---|
23 | System.out.printf( " %s\n", t2.toString() ); |
---|
24 | |
---|
25 | System.out.println( |
---|
26 | "t3: hour and minute specified; second defaulted" ); |
---|
27 | System.out.printf( " %s\n", t3.toUniversalString() ); |
---|
28 | System.out.printf( " %s\n", t3.toString() ); |
---|
29 | |
---|
30 | System.out.println( "t4: hour, minute and second specified" ); |
---|
31 | System.out.printf( " %s\n", t4.toUniversalString() ); |
---|
32 | System.out.printf( " %s\n", t4.toString() ); |
---|
33 | |
---|
34 | System.out.println( "t5: all invalid values specified" ); |
---|
35 | System.out.printf( " %s\n", t5.toUniversalString() ); |
---|
36 | System.out.printf( " %s\n", t5.toString() ); |
---|
37 | |
---|
38 | System.out.println( "t6: Time2 object t4 specified" ); |
---|
39 | System.out.printf( " %s\n", t6.toUniversalString() ); |
---|
40 | System.out.printf( " %s\n", t6.toString() ); |
---|
41 | } // end main |
---|
42 | } // end class Time2Test |
---|
43 | |
---|
44 | |
---|
45 | /************************************************************************** |
---|
46 | * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and * |
---|
47 | * Pearson Education, Inc. All Rights Reserved. * |
---|
48 | * * |
---|
49 | * DISCLAIMER: The authors and publisher of this book have used their * |
---|
50 | * best efforts in preparing the book. These efforts include the * |
---|
51 | * development, research, and testing of the theories and programs * |
---|
52 | * to determine their effectiveness. The authors and publisher make * |
---|
53 | * no warranty of any kind, expressed or implied, with regard to these * |
---|
54 | * programs or to the documentation contained in these books. The authors * |
---|
55 | * and publisher shall not be liable in any event for incidental or * |
---|
56 | * consequential damages in connection with, or arising out of, the * |
---|
57 | * furnishing, performance, or use of these programs. * |
---|
58 | *************************************************************************/ |
---|