Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BINATANG {
- String nama,jenis,habitat;
- BINATANG(String nm, String jns, String hbtt){
- nama = nm;
- jenis = jns;
- habitat = hbtt;
- System.out.println("Nama Binatang : "+nama);
- System.out.println("Jenis : "+jenis);
- System.out.println("Habitat : "+habitat);
- }
- void suara(){
- switch (nama){
- case "Anjing" : System.out.println("pinjem duit dong besok gw ganti"); break;
- case "Kucing" : System.out.println("Aih malunya aku");break;
- case "Buaya" : System.out.println("Km sudah punya cowok kah?");break;
- default : System.out.println("gada suara");
- }
- }
- public static void main(String[] args) {
- BINATANG binatang1 = new BINATANG("Anjing", "Humanis Dog", "Kompleks");
- binatang1.suara();
- System.out.println("");
- BINATANG binatang2 = new BINATANG("Kucing", "Teaser Cat", "Warung");
- binatang2.suara();
- System.out.println("");
- BINATANG binatang3 = new BINATANG("Buaya", "Player", "Hati");
- binatang3.suara();
- }
- }
Add Comment
Please, Sign In to add comment