//--------------------
//mahasiswa.java
//--------------------
package polimorfismtugas;
public class mahasiswa {
public String nama;
public String nmp;
public mahasiswa(String n, String m) {
nama = n;
nmp = m;
}
public String tampilkanNama() {
return nama;
}
public String tampilkanNmp() {
return nmp;
}
void belajar() {
System.out.println("Baca...Latihan....Tugas...POKO'E BELAJAR");
}
public void olahraga() {
System.out.println("1...2...3...olahraga biar sehat");
}
public void makan() {
System.out.println("Nyam..nyam...nyam...maem enak");
}
public void minum() {
System.out.println("hemmm....minum biar seger...");
}
public void aktivitas() {
System.out.println("kuliah..belajar...dll...");
}
}
public class mahasiswa {
public String nama;
public String nmp;
public mahasiswa(String n, String m) {
nama = n;
nmp = m;
}
public String tampilkanNama() {
return nama;
}
public String tampilkanNmp() {
return nmp;
}
void belajar() {
System.out.println("Baca...Latihan....Tugas...POKO'E BELAJAR");
}
public void olahraga() {
System.out.println("1...2...3...olahraga biar sehat");
}
public void makan() {
System.out.println("Nyam..nyam...nyam...maem enak");
}
public void minum() {
System.out.println("hemmm....minum biar seger...");
}
public void aktivitas() {
System.out.println("kuliah..belajar...dll...");
}
}
//--------------------------------------------------------
//--------------------
//pecintaalam.java
//-------------------- package polimorfismtugas;
class pecintaalam extends mahasiswa {
public String UKM;
public String bagian;
public pecintaalam(String n, String m, String u, String b) {
super(n, m);
this.UKM = u;
this.bagian = b;
}
public String tampilkanUKM() {
return UKM;
}
public String tampilkanBagian() {
return bagian;
}
@Override
public void aktivitas() {
System.out.println("mendaki gunung.....!!!");
}
public void refresh() {
System.out.println("camping yuk...");
}
}
class shinta {
public static void main(String[] args) {
rohis saya = new rohis("shinta", "153", "hemo");
System.out.println("Nama= " + saya.tampilkanNama()
+ "\nNIM = " + saya.tampilkanNmp()
+ "\nsebagai = " + saya.tampilkanBagian()
+ "\nkegiatannya.....");
saya.aktivitas();
System.out.println("\ndan trus...");
saya.agenda();
}
}
class pecintaalam extends mahasiswa {
public String UKM;
public String bagian;
public pecintaalam(String n, String m, String u, String b) {
super(n, m);
this.UKM = u;
this.bagian = b;
}
public String tampilkanUKM() {
return UKM;
}
public String tampilkanBagian() {
return bagian;
}
@Override
public void aktivitas() {
System.out.println("mendaki gunung.....!!!");
}
public void refresh() {
System.out.println("camping yuk...");
}
}
//--------------------------------------------------------
//--------------------
//rohis.java
//--------------------package polimorfismtugas;
public class rohis extends mahasiswa {
public String bagian;
public rohis(String n, String m, String b) {
super(n, m);
this.bagian = b;
}
public String tampilkanBagian() {
return bagian;
}
@Override
public void aktivitas() {
System.out.println("tidur aja lah....");
}
public void agenda() {
System.out.println("mkan malam yang indah...");
}
}
public class rohis extends mahasiswa {
public String bagian;
public rohis(String n, String m, String b) {
super(n, m);
this.bagian = b;
}
public String tampilkanBagian() {
return bagian;
}
@Override
public void aktivitas() {
System.out.println("tidur aja lah....");
}
public void agenda() {
System.out.println("mkan malam yang indah...");
}
}
//--------------------------------------------------------
package polimorfismtugas;//--------------------
//shinta.java
//--------------------class shinta {
public static void main(String[] args) {
rohis saya = new rohis("shinta", "153", "hemo");
System.out.println("Nama= " + saya.tampilkanNama()
+ "\nNIM = " + saya.tampilkanNmp()
+ "\nsebagai = " + saya.tampilkanBagian()
+ "\nkegiatannya.....");
saya.aktivitas();
System.out.println("\ndan trus...");
saya.agenda();
}
}
2 comments:
bagus ini! thanks yaa bikin terinspirasi buat tugas :)
sama2..semoga bermanfaat :)
Posting Komentar