2012420031
Postingan ini merupakan kelanjutan dari tugas 5 kemarin,hanya dibubuhi dgn konsep overriding..
package tugas5algo2;
public class toko {
public String makanan;
public String minuman;
public String pakaian;
void nama (){
}
void alamat(){
}
void perusahaan(){
}
}
class indomart extends toko{
@Override
void nama(){
System.out.println("nama : indomart");
}
@Override
void alamat(){
System.out.println("alamat : Jl.Tropodo");
}
@Override
void perusahaan(){
System.out.println("milik PT.IndoRaya");
}
}
class alfamart extends toko{
@Override
void nama(){
System.out.println("nama : Alfamart");
}
@Override
void alamat(){
System.out.println("alamat : Jl.kenjeran");
}
@Override
void perusahaan(){
System.out.println("milik PT.AlfaRaya");
}
}
class Ck extends toko{
@Override
void nama(){
System.out.println("nama : Ck mart");
}
@Override
void alamat(){
System.out.println("alamat : Jl.sedati");
}
@Override
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 adalah :
Posted by 11.50 and have
0
komentar
, Published at
Tidak ada komentar:
Posting Komentar