Langsung ke konten utama

Latihan 8.1 - 8.6 || TASK 2

BIODATA
/**

 * Write a description of class Profile here.

 *

 * @author (your name)

 * @version (a version number or a date)

 */

public class Biodata

{
    public static void main( String[] args )
    {

        System.out.println ("---------- BIODATA ----------");

        System.out.println ("\n");

        System.out.println ("Nama       : Muhammad Satryo Pamungkas Bimasakti");

        System.out.println ("NRP        : 05111840000070");

        System.out.println ("Kelas      : PBO-D");
       
        System.out.println ("Alamat      : Central Park");
    }

}


Hasil Compile ::



_________________________________________________________________________________

Tugas Time 

Membuat New Class Time1


public class Time1
{
    private int hour; // 0 - 23
    private int minute; // 0 - 59
    private int second; // 0 - 59
    
    // set a new time value using universal time; throw an
    // exception if the hour, minute or second is invalid
    public void setTime( int h, int m, int s )
    {
        // validate hour, minute and second
        if ( ( h >= 0 && h < 24 ) && ( m >= 0 && m < 60 ) && 
           ( s >= 0 && s < 60 ) )
        {
            hour= h;
            minute= m;
            second= s;
        } // end if
        else
           throw new IllegalArgumentException(
            "hour, minute and/or second was out of range" );
   } // end method setTime

   // convert to String in universal-time format (HH:MM:SS)
    public String toUniversalString()
    {
        return String.format( "%02d:%02d:%02d", hour, minute, second );
    } // end method toUniversalString

    // convert to String in standard-time format (H:MM:SS AM or PM)
    public String toString()
    {
     return String.format( "%d:%02d:%02d %s",
     ( ( hour == 0 || hour == 12 ) ? 12 : hour % 12 ),
     minute, second, ( hour < 12 ? "AM" : "PM" ) );


    } // end method toString
 } // end class Time1



Setelah itu membuat Time1Test





public class Time1Test 
{
    public static void main( String[] args )
    {
            // create and initialize a Time1 object
            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
        
            // change time and output updated time
            time.setTime( 13, 27, 6 );
            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
        
            // attempt to set time with invalid values
            try
            {
                time.setTime( 99, 99, 99 ); // all values out of range
            } // end try
            catch ( IllegalArgumentException e )
            {
            System.out.printf( "Exception: %s\n\n", e.getMessage() );
            } // end catch
        
            // display time after attempt to set invalid values
            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() );
    } // end main
} // end class CopyOfCopyOfTime1Tesc    


Hubungan Time1 dan Time1Test Akan menjadi seperti ini ::




Dan hasilnya akan seperti ini ::










Komentar

Postingan populer dari blog ini

Portofolio Aplikasi

Maddi Website Website ini menggunakan framework django, tailwind dan bootstrap. Memiliki fitur seperti login, register, keranjang belanja, dan fitur-fitur lainya. tetapi website ini belum di deploy jadi untuk membukanya masih menggunakan localhost. Dan pada saat pernah membuat aplikasi POS simple menggunakan program java.  

DOTA 2

TPG _ Review Game DOTA 2 Klasifikasi Game Genre : MOBA (Multiplayer Online Battle Arena) , Strategy Tema : Fantasy Rating : No Rating (ESRB) Metacritic Rating : 90 Publisher : Valve Corporation Release Date : July 9, 2013 Deskripsi Dota 2 adalah video game multiplayer online battle arena (MOBA) 2013 yang dikembangkan dan diterbitkan oleh Valve. Gim ini merupakan sekuel Defense of the Ancients (DotA), yang merupakan mod buatan komunitas untuk Warcraft III: Reign of Chaos dari Blizzard Entertainment. Dota 2 dimainkan dalam pertandingan antara dua tim yang terdiri dari lima pemain, dengan masing-masing tim menempati dan mempertahankan markas mereka sendiri di peta. Masing-masing dari sepuluh pemain secara independen mengontrol karakter kuat yang dikenal sebagai "pahlawan" yang semuanya memiliki kemampuan unik dan gaya permainan yang berbeda. Selama pertandingan, pemain mengumpulkan poin pengalaman dan item untuk pahlawan mereka agar berhasil mengalahkan pahlawan tim lawan

Structured Programming VS Object Based Programming || TASK 1

Structured Programming Object-oriented programming Break down programs in functions and data Combine functions and data in classes or objects It has the characteristics of Sequence, Selection and Repetition It has the characteristics of Encapsulation (packaging), Inheritance (inheritance) and Polymorphism (differences in shape and behavior) The program structure is complicated because it is a sequence of processes and functions The program structure is concise, enough to create objects and classes and then work based on these objects and classes. Lacking program reusing The program code is very reusable. object and class can be used many times, so as to save memory space. Effectively used to solve small problems and not suitable for solving complex problems, because later it will be difficult to find solutions to problems when an error occurs Effectively used to solve large problems, because OOP consists of classes that separate each program