Minggu, 19 Mei 2013

Tugas Praktik RPL

|0 komentar


package vehicle;

    public class Vehicle {
        String owner, color, merk;
        int wheel, speed;
        
        void Owner(String o, int w){
        owner=o;
        wheel=w;
        }
        
        void Type(String c, String m, int s){
        color=c;
        merk=m ;
        speed=s;
        }
        
        static void Line(){
        System.out.println("+-------------------------------------+");
        }
        
        void Show(){
        Line();
        System.out.println("Nama Pemilik : "+owner);
        System.out.println("Jumlah Roda  : "+wheel);
        System.out.println("Warna        : "+color);
        System.out.println("Merk         : "+merk);
        System.out.println("Speed        : "+speed+" km/jam");
    }

    public static void main(String[] args){
        Vehicle Motor = new Vehicle();
        Motor.Owner ("Hatsune Miku",2);
        Motor.Type("Cyan","Vocaloid",300);
        Motor.Show();
    
        Vehicle Mobil = new Vehicle();
        Mobil.Owner ("Hatsune Miku",4);
        Mobil.Type("Silver","Sirlon",350);
        Mobil.Show();
        Line();
    
        System.out.println();
        for(int i =0; i<= 100; i++){
            System.out.println("Mobil melaju dengan kecepatan "+i+" km/jam");
            if (i==100){
            break;
            }
        }
    
        System.out.println();
        // Pengeremman
        for(int a = 100; a >= 0 ; a--){
            System.out.println("Kecepatan mobil menurun sampai "+a+" km/jam");
            if (a==0){
            break;
            }
        }
    }
}

♫ BGM ♫