Skip to content

Instantly share code, notes, and snippets.

@agusmakmun
Last active August 29, 2015 14:20
Show Gist options
  • Save agusmakmun/7ecaaf3b0caf799a1905 to your computer and use it in GitHub Desktop.
Save agusmakmun/7ecaaf3b0caf799a1905 to your computer and use it in GitHub Desktop.
Ini adalah script cecker Admin, dengan menggunakan 2 constructor yang berbeda. Dan 1 method berupa apakahAdmin(), digunakan untuk check admin.
/*
Ini adalah script cecker Admin, dengan menggunakan 2 constructor yang berbeda.
Dan 1 method berupa apakahAdmin(), digunakan untuk check admin.
Lihat soalnya : https://gist.github.com/agusmakmun/3255042298910fd3f2c5
Lihat pemanggilannya : https://gist.github.com/agusmakmun/a22db6e9a879f03545f8
@author Summon Agus
@blog bloggersmart.net
*/
public class CekUser {
String idku = "Summon";
String passwordku = "Agus";
String id;
String password;
String nama;
String admin;
public CekUser (String id, String password) {
this.id = id;
this.password = password;
}
public CekUser (String id, String password, String nama, String admin) {
this.id = id;
this.password = password;
this.nama = nama;
this.admin = admin;
}
public boolean apakahAdmin() {
if (id.equals(idku) && password.equals(passwordku)) {
System.out.println("id = "+id+ "; password = "+password+"; ----> Benar, Selamat Datang Admin");
return true;
}
else {
System.out.println("Salah, Anda Bukan Admin");
return false;
}
}
}
// Result of Output
Salah, Anda Bukan Admin
id = Summon; password = Agus; ----> Benar, Selamat Datang Admin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment