* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package polimerfisme;
/**
*
* @author User
*/
public class transportasi {
/**
* @param args the command line arguments
*/
private String nama;
private String transit;
private String bahanbakar;
public void nama(String nama){
System.out.println("Nama Kendaraan: "+getNama());
}
public void nama(String transit, String bahanbakar){
System.out.println("Tempat transit: "+getTransit());
System.out.println("Jenis Bahan Bakar: "+getBahanbakar());
}
/**
* @return the nama
*/
public String getNama() {
return nama;
}
/**
* @param nama the nama to set
*/
public void setNama(String nama) {
this.nama = nama;
}
/**
* @return the transit
*/
public String getTransit() {
return transit;
}
/**
* @param transit the transit to set
*/
public void setTransit(String transit) {
this.transit = transit;
}
/**
* @return the bahanbakar
*/
public String getBahanbakar() {
return bahanbakar;
}
/**
* @param bahanbakar the bahanbakar to set
*/
public void setBahanbakar(String bahanbakar) {
this.bahanbakar = bahanbakar;
}
}
public class transportasidarat extends transportasi{
private int roda;
public void jumlah(int roda){
System.out.println("Jumlah Roda: "+getRoda());
}
/**
* @return the roda
*/
public int getRoda() {
return roda;
}
/**
* @param roda the roda to set
*/
public void setRoda(int roda) {
this.roda = roda;
}
public static void main(String[] args) {
transportasi x = new transportasi();
x.setNama("bus kota");
x.nama(x.getNama());
x.setTransit("terminal");
x.setBahanbakar("solar dan premium");
x.nama(x.getTransit(), x.getBahanbakar());
transportasidarat y = new transportasidarat();
y.setRoda(4);
y.jumlah(y.getRoda());
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package polimerfisme;
/**
*
* @author User
*/
public class transportasilaut {
public void menyelam (){
System.out.println("Bisa Menyelam di Dalam Laut");
}
public static void main(String[] args) {
transportasi x = new transportasi();
x.setNama("kapal selam");
x.nama(x.getNama());
x.setTransit("pelabuhan");
x.setBahanbakar("hidrogen , solar");
x.nama(x.getTransit(), x.getBahanbakar());
transportasilaut a = new transportasilaut();
System.out.print(x.getNama()+ " ");
a.menyelam();
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package polimerfisme;
/**
*
* @author User
*/
public class transportasiudara {
private int roda, sayap;
public void jumlah (int roda , int sayap){
System.out.println("Jumlah Roda: "+getRoda());
System.out.println("Jumlah Sayap: "+getSayap());
}
/**
* @return the roda
*/
public int getRoda() {
return roda;
}
/**
* @param roda the roda to set
*/
public void setRoda(int roda) {
this.roda = roda;
}
/**
* @return the sayap
*/
public int getSayap() {
return sayap;
}
/**
* @param sayap the sayap to set
*/
public void setSayap(int sayap) {
this.sayap = sayap;
}
public static void main(String[] args) {
transportasi x = new transportasi();
x.setNama("pesawat");
x.nama(x.getNama());
x.setTransit("bandara");
x.setBahanbakar("aftur");
x.nama(x.getTransit(), x.getBahanbakar());
transportasiudara z = new transportasiudara();
z.setRoda(3);
z.setSayap(2);
z.jumlah(z.getRoda(), z.getSayap());
}
}
Posted by 23.21 and have
0
komentar
, Published at
Tidak ada komentar:
Posting Komentar