download file java ada di bawah , Semoga Bermanfaat .
Codingan :
public class radioon {
public String Nama;
public Boolean on = false;
public int volume=0;
public double frekuensi=0;
public String ret;
public void print_radio(String Temp){
System.out.println("\nObjek Radio "+Nama+" Berhasil Di buat");
}
public void print_radio(double frekuensi){
System.out.println("Frekuensi Radio "+Nama+" adalah "+frekuensi+" FM");
}
public void print_radio(int volume, boolean on){
if (on==true)
ret="Radio Nyala";
else
ret="Radio Mati";
if (volume > 0)
ret +=" Dengan Volume "+volume;
System.out.println(ret);
}
public String getNama(){
return Nama;
}
public void setNama(String Temp){
Nama=Temp;
}
public double getfrekuensi(){
return frekuensi;
}
public void setfrekuensi(double frekuensi){
this.frekuensi=frekuensi;
}
public int getvolume(){
return volume;
}
public void setvolume(int volume){
this.volume=volume;
}
public boolean geton(){
return on;
}
public void seton(boolean on){
this.on=on;
}
public static void main(String[] args) {
radioon a=new radioon();
a.setNama("Gen FM");
a.setfrekuensi(108.9);
a.seton(false);
a.setvolume(0);
a.print_radio(a.getNama());
a.print_radio(a.getfrekuensi());
a.print_radio(a.getvolume(), a.geton());
radioon x=new radioon();
x.setNama("Unitomo FM");
x.setfrekuensi(107.7);
x.seton(true);
x.setvolume(100);
x.print_radio(x.getNama());
x.print_radio(x.getfrekuensi());
x.print_radio(x.getvolume(), x.geton());}
}
Output :
Objek Radio dengan Method overloading, acceseor , mutator
Nama : IRWAN SYAH
Nim : 2012420052
Kelas : A
Jurusan : Informatika
Unitomo
Posted by 13.14 and have
0
komentar
, Published at
Tidak ada komentar:
Posting Komentar