import javax.swing.*;
class manusia {
private String manusia;
public void set_manusia(String nama) {
manusia = nama;
}
public String get_Manusia() {
return manusia;
}
}
class mahasiswa extends manusia {
private String npm;
private String maha;
public void set_npm(String no_id) {
npm = no_id;
}
public String get_npm(){
return npm;
}
public void set_maha(String ipk) {
maha = ipk;
}
public String get_maha(){
return maha;
}
}
class pekerja extends mahasiswa{
private String pekerja;
private String gaj;
public void set_pekerja(String nama) {
pekerja = nama;
}
public String get_pekerja(){
return pekerja;
}
public void set_gaj(String gaji) {
gaj = gaji;
}
public String get_gaj(){
return gaj;
}
}
CLASS LAIN
import javax.swing.*;
public class mahasiwa {
public static void main(String[] args) {
pekerja x = new pekerja();
x.set_manusia(JOptionPane.showInputDialog("Masukkan Nama"));
x.set_maha(JOptionPane.showInputDialog("Masukkan IPK"));
x.set_npm(JOptionPane.showInputDialog("Masukkan NPM"));
x.set_pekerja(JOptionPane.showInputDialog("Masukkan ID Pekerja"));
x.set_gaj(JOptionPane.showInputDialog("Masukkan Jumlah Gaji"));
System.out.println("Nama : "+x.get_Manusia());
System.out.println("IPK : "+x.get_maha());
System.out.println("NPM : "+x.get_npm());
System.out.println("ID pekerja : "+x.get_pekerja());
System.out.println("Jumlah Gaji : "+x.get_gaj());
}
}
Run:
Nama : Luk Lu'ul Marjan
IPK : 3.5
NPM : 1135010025
ID pekerja : 12345678
Jumlah Gaji : 3.000.000
BUILD SUCCESSFUL (total time: 50 seconds)CAPTURE
Tidak ada komentar:
Posting Komentar