NIK : 2012420031
Pada postingan tugas kali nie,saya mencoba meng-coding
dgn konsep polimorfisme dgn objek "toko"..
(NB : "nama,alamat dan pemilik perusahaan tidak sebenarnya")
package tugas5algo2;
public class toko {
}
class indomart extends toko{
void nama(){
System.out.println("nama : indomart");
}
void alamat(){
System.out.println("alamat : Jl.Tropodo");
}
void perusahaan(){
System.out.println("milik PT.IndoRaya");
}
}
class alfamart extends toko{
void nama(){
System.out.println("nama : Alfamart");
}
void alamat(){
System.out.println("alamat : Jl.kenjeran");
}
void perusahaan(){
System.out.println("milik PT.AlfaRaya");
}
}
class Ck extends toko{
void nama(){
System.out.println("nama : Ck mart");
}
void alamat(){
System.out.println("alamat : Jl.sedati");
}
void perusahaan(){
System.out.println("Milik PT.CakraRaya");
}
public static void main(String[] args) {
indomart a = new indomart();
a.nama();
a.alamat();
a.perusahaan();
System.out.println("==========================");
alfamart b = new alfamart();
b.nama();
b.alamat();
b.perusahaan();
System.out.println("===========================");
Ck c = new Ck();
c.nama();
c.alamat();
a.perusahaan();
System.out.println("============================");
}
}
hasilnya :
Posted by 11.34 and have
0
komentar
, Published at
Tidak ada komentar:
Posting Komentar