Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Objek Time1 diaplikasikan disini
- import static org.junit.Assert.*;
- import org.junit.After;
- import org.junit.Before;
- import org.junit.Test;
- /**
- * 8.2 Time1Test.
- *
- * @thomasdwi
- * @20201011
- */
- public class Time1Test
- {
- public static void main( String[] args){
- //membuat dan menginisiasi objek Time1
- Time1 time = new Time1(); //memanggil konstruktur Time1
- //output string yang mempresentasikan waktu
- 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();
- // merubah waktu dan memberi output waktu yang telah dirubah
- time.setTime( 13, 27, 6);
- 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();
- // memcoba untuk set nilai waktu yang tidak valid
- try
- {
- time.setTime(99, 99, 99); // semua nilai diluar range
- }
- catch ( IllegalArgumentException e )
- {
- System.out.printf("Exception: %s\n\n", e.getMessage());
- }
- //menampilkan waktu setelah percobaan diatas
- 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() );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement