Sabtu, 09 Maret 2013

Pengenalan Class Object Method Attribute


Source code java

public class Handphone {
    String merk;
    String type;
    String os;
    String keypad;
    int price;

    public void set(String merk, String type, String os,String keypad,int price) {
         this.merk = merk;
         this.type = type;
         this.os = os;
         this.keypad = keypad;
         this.price= price;
    }
  
    public void appear() {
        System.out.println("Handphone Information");
        System.out.println("Merk : "+ merk);
        System.out.println("Type : " + type);
        System.out.println("OS : "+ os);
        System.out.println("Keypad : "+ keypad);
        System.out.println("Price: "+ price);
    }
}

class HP {
    public static void main(String[] args) {
        Handphone Samsung = new Handphone();
        Handphone Nokia = new Handphone();
        Samsung.set("Samsung","Galaxy Ace Duos S6802","Android OS, v2.3 (Gingerbread)","Touchscreen",1950000);
        Samsung.appear();
        System.out.print("\n");
        Nokia.set("Nokia", "Lumia 900", "Microsoft Windows Phone 7.5 Mango","Touchscreen",5500000);
        Nokia.appear();
    } 
}