Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Contoh aplikasi Time1 sebagai object
- *
- *
- *
- */
- public class Time1Test
- {
- public static void main( String[] args )
- {
- // membuat dan menginisialisasi object Time1
- Time1 time = new Time1(); // invokes Time1 constructor
- // output string representations of the time
- System.out.print( "The initial universal time is: " );
- System.out.println( time.toUniversalString() );
- System.out.print( "The initial standard time is: " );
- System.out.println( time.toString() );
- System.out.println(); // output a blank line
- // ganti dengan input waktu yang baru
- time.setTime(13, 30, 4);
- System.out.print( "Universal time after setTime is: " );
- System.out.println( time.toUniversalString() );
- System.out.print( "Standard time after setTime is: " );
- System.out.println( time.toString() );
- System.out.println(); // output a blank line
- // coba input waktu dengan nilai yang invalid
- try
- {
- time.setTime( 99,99, 99 ); // semua nilai yang out of range
- } // akhir dari try
- catch ( IllegalArgumentException e )
- {
- System.out.printf( "Exception: %s\n\n", e.getMessage() );
- } // akhir dari catch
- // menampilkan waktu setelah mencoba menginput dengan data yang invalid
- System.out.println( "After attempting invalid settings:" );
- System.out.print( "Universal time: " );
- System.out.println( time.toUniversalString() );
- System.out.print( "Standard time: " );
- System.out.println( time.toString() );
- } // akhir dari main
- } // akhir dari class Time1Test
Advertisement
Add Comment
Please, Sign In to add comment