public class alattransportasi {
String nama;
String jenis;
String bahanbakar;
public void mesin(){
System.out.println("Memiliki Mesin");
}
public void nama(){
System.out.println("Alat transportasi darat dan laut");
}
}
class bus extends alattransportasi{
public void namatransportasi(){
System.out.println("Nama Transportasi = "+nama);
}
public void jenis(){
System.out.println("Jenis Transportasi = "+jenis);
}
public void bahanbakar(){
System.out.println("Bahan Bakar = "+bahanbakar);
}
}
class motor extends alattransportasi{
public void namatransportasi(){
System.out.println("nama transportasi = "+nama);
}
public void jenis(){
System.out.println("nama transportasi ="+jenis);
}
public void bahanbakar(){
System.out.println("nama transportasi ="+bahanbakar);
}
}
class pesawat extends alattransportasi{
public void namatransportasi(){
System.out.println("nama transportasi = "+nama);
}
public void jenis(){
System.out.println("nama transportasi ="+jenis);
}
public void bahanbakar(){
System.out.println("nama transportasi ="+bahanbakar);
}
public static void main(String[] args) {
alattransportasi x = new alattransportasi();
x.nama();
x.mesin();
bus y =new bus();
y.nama="Bus";
y.jenis="darat";
y.bahanbakar="solar";
y.namatransportasi();
y.jenis();
y.bahanbakar();
motor u =new motor();
u.nama="motor";
u.jenis="darat";
u.bahanbakar="bensin";
u.namatransportasi();
u.jenis();
u.bahanbakar();
pesawat t =new pesawat();
t.nama="Bus";
t.jenis="darat";
t.bahanbakar="solar";
t.namatransportasi();
t.jenis();
t.bahanbakar();
}
}
Posted by 08.55 and have
0
komentar
, Published at
Tidak ada komentar:
Posting Komentar