1.
KelasKendaraanSuper.java
class KelasKendaraanSuper{
pulic void methodAsli(){
string roda;
string stang;
string sadel;
System.out.println("Method milik KelasKendaraanSuper jalan");
}
public static void jalankan (String[]args){
KelasKendaraanSuper oks=new KelasKendaraanSuper();
oks.methodAsli();
}
void rem (String[]args){
KelasKendaraanSuper oks=new KelasKendaraanSuper();
oks.methodAsli();
}
}
SubKelasMotor.java
class SubKelasMotor extends KelasKendaranSuper{
public void methodAsli(){
System.out.println("method overrided jalan");
}
public void methodJumping(){
roda=2;
System.out.println("kendaraan ber-roda "+roda)
Super.methodAsli();
}
public static void main(String[]args){
Subkelas osk=new SubKelas();
osk.methodASli();
osk.merhodJumping();
}
}
SubKelasMobil.java
class SubKelasMobil extends KelasKendaranSuper{
public void methodAsli(){
System.out.println("method overrided jalan");
}
public void methodMundur(){
roda=4;
System.out.println("kendaraan ber-roda "+roda)
Super.methodAsli();
}
public static void main(String[]args){
Subkelas osk=new SubKelas();
osk.methodASli();
osk.merhodMundur();
}
}
2. Segitiga.java
public class Segitiga{
private double alas; //attribute yang di hide
private double tinggi;//attribute yang di hide
public Segita(){
alas=0;
tinggi=0;
}
private double luas(double a,double t){//encapsulation
return a*t/2;
}
public void setAlas(double alas){
this.alas=alas;
}
public void setTinggi(double tinggi){
this.tinggi=tinggi;
}
public double getAlas(){
return alas;
}
public double getTinggi(){
return tinggi;
}
Public double getLuas(){
return luas(alas, tinggi);
}
}
==========================
NAMA : PUSPA NUR FAJARWATI
NPM : 11108527
KELAS: 3KA16
==========================
Label:
tUgAs
Selasa, 09 November 2010
Langganan:
Postingan (Atom)