Buku Alamat mengunakan Java

public class BukuAlamat{

//Instance Variable dan Static Variable

private static int intContactCount = 0;

private String strNama;

private String strAlamat;

private String strNoTlp;

private String strEmail;

 //Accessor Methods

public String getNama(){    return strNama;  }

 public String getAlamat(){    return strAlamat;  }

 public String getNoTlp(){    return strNoTlp;  }

 public String getEmail(){    return strEmail;  }

//Mutator Methods

public void setNama(String temp){    strNama = temp;  }

 public void setAlamat(String temp){    strAlamat = temp;  }

 public void setNoTlp(String temp){    strNoTlp = temp;  }

 public void setEmail(String temp){    strEmail = temp;  }

//Constructor

public BukuAlamat(){    intContactCount++;  }

 public BukuAlamat(String nama, String alamat, String notlpn, String email){

    this.strNama = nama;

    this.strAlamat = alamat;

    this.strNoTlp = notlpn;

    this.strEmail = email;

    intContactCount++;  }

//Main Procedure

public static void main(String[] args){

    BukuAlamat wulan = new BukuAlamat();

    BukuAlamat elis = new BukuAlamat(“elis”, “Depok”, “0857905306”, “elis@yahoo.com”);

    wulan.setNama(“wulan Dp”);

    wulan.setAlamat(“Depok”);

    wulan.setNoTlp(“02198749074”);

    wulan.setEmail(“wulan@yahoo.com”);

    System.out.println(“Nama:  “+” “+ wulan.getNama());

    System.out.println(“Alamat:”+” “+ wulan.getAlamat());

    System.out.println(“No.Tlp:”+” “+ wulan.getNoTlp());

    System.out.println(“Email: “+” “+ wulan.getEmail());

    System.out.println(“\nNama:  “+” “+ elis.getNama());

    System.out.println(“Alamat:”+” ” + elis.getAlamat());

    System.out.println(“No.Tlp:”+” ” + elis.getNoTlp());

    System.out.println(“Email: “+” ” + elis.getEmail());

    System.out.println(“\nJumlah Kontak: ” + intContactCount);

}

}

Output

About heni
I ♡ movie, traveling, fruits Worry less smile more fell happy anyway :)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: