Selasa, 10 Desember 2013

Tugas Akhir Praktikum PBO


Class Manusia :
import javax.swing.JOptionPane;
public class manusia {
private String nama;
private String alamat;
private String jeniskelamin;
private String kota;
private int umur;
public manusia() {
nama = "";
alamat = "";
jeniskelamin = "";
kota = "";
umur = 0;
}
public manusia(String newNama, String newAlamat,  String newjeniskelamin, String newKota, int
newUmur) {
nama = newNama;
alamat = newAlamat;
jeniskelamin = newjeniskelamin;
kota = newKota;
umur = newUmur;
}
public void setNama (){
nama = JOptionPane.showInputDialog("nama :: ");
}
public String getNama (){
return nama;
}
public void setAlmat (){
alamat = JOptionPane.showInputDialog("alamat :: ");
}
public String getAlamat (){
return alamat;
}
public void setjeniskelamin (){
jeniskelamin = JOptionPane.showInputDialog("jeniskelamin :: ");
}
public String getjeniskelamin (){
return jeniskelamin;
}
public void setKota () {
kota = JOptionPane.showInputDialog("kota :: ");
}
public String getKota (){
return kota;
}
public void setUmur () {
String data;
data = JOptionPane.showInputDialog("umur :: ");
umur = Integer.parseInt(data);
}
public int getUmur (){
return umur;
}

}

Class Mahasiswa :
import javax.swing.JOptionPane;
public class mahasiswa extends manusia {
private int nim;
private String strata;
private String Jurusan;
public mahasiswa() {
super ();
nim = 0;
Jurusan = "";
strata = "";
}
public mahasiswa (String newNama, String newAlamat,  String newjeniskelamin, String newKota, int
newUmur, int newnim, String newStrata, String newJurusan) {
super(newNama, newAlamat, newjeniskelamin, newKota, newUmur);
nim = newnim;
Jurusan = newJurusan;
strata = newStrata;
}
public void setnim () {
String data;
data = JOptionPane.showInputDialog("Nim :: ");
nim = Integer.parseInt(data);
}
public int getnim () {
return nim;
}
public void setJurusan () {
Jurusan = JOptionPane.showInputDialog("jurusan :: ");
}
public String getJurusan() {
return Jurusan;
}
public void setStrata () {
strata = JOptionPane.showInputDialog("strata :: ");
}
public String getStrata () {
return strata;
}
}

Class Dosen :
import javax.swing.JOptionPane;
public class dosen extends manusia {
private String nik;
private String fakultas;
public dosen() {
super ();
nik = "";
fakultas = "";
}
public dosen (String newNama, String newAlamat,  String newjeniskelamin, String newKota, int
newUmur, String newnik, String newfakultas) {
super(newNama, newAlamat, newjeniskelamin, newKota, newUmur);
nik = newnik;
fakultas = newfakultas;
} 
public void setnik () {
nik = JOptionPane.showInputDialog("nik :: ");
}
public String getnik () {
return nik;
}
public void setfakultas () {
fakultas = JOptionPane.showInputDialog("fakultas :: ");
}
public String getfakultas() {
return fakultas;
}

Class Materi Kulia :
import javax.swing.JOptionPane;
public class mata_kuliah extends mahasiswa {
private int counter;
private String mata_kuliah1;
private int sks,n;
public mata_kuliah() {
super ();
counter = 0;
mata_kuliah1 = "";
sks = 0;
}
public mata_kuliah (String newNama, String newAlamat,  String newjeniskelamin, String newKota, int
newUmur, int newnim, String newStrata, String newJurusan, int newcounter, String newmata_kuliah1, int newsks) {
super(newNama, newAlamat, newjeniskelamin, newKota, newUmur, newnim, newStrata, newJurusan);
counter = newcounter;
mata_kuliah1 = newmata_kuliah1;
sks = newsks;
}
public void mata_kuliah1 (){
 String data;
 data = JOptionPane.showInputDialog("diambil :: ");
 n = Integer.parseInt(data);
 counter = 1;
 while ( counter <= n ) {
    mata_kuliah1 = JOptionPane.showInputDialog("Mata Kuliah :: ");
    data = JOptionPane.showInputDialog("SKS :: ");
    sks = Integer.parseInt(data);
    System.out.print(counter+".  "+mata_kuliah1);
    System.out.println("\t \t \t  "+sks);
     counter++;
   }
}
}

Class Mengajar :
import javax.swing.JOptionPane;
public class Mengajar extends dosen {
private int counter;
private String mengajar1;
private int n,sks;
public Mengajar() {
super ();
counter = 0;
mengajar1 = "";
sks = 0;
}
public Mengajar (String newNama, String newAlamat,  String newjeniskelamin, String newKota, int
newUmur, String newnik, String newfakultas, int newcounter, String newmengajar1, int newsks) {
super(newNama, newAlamat, newjeniskelamin, newKota, newUmur, newnik, newfakultas);
counter = newcounter;
mengajar1 = newmengajar1;
sks = sks;
}
public void Mengajar1 (){
 String data;
 data = JOptionPane.showInputDialog("diambil :: ");
 n = Integer.parseInt(data);
 counter = 1;
 while ( counter <= n ) {
    mengajar1 = JOptionPane.showInputDialog("Mata Kuliah :: ");
    data = JOptionPane.showInputDialog("SKS :: ");
    sks = Integer.parseInt(data);
    System.out.print(counter+".  "+mengajar1);
    System.out.println("\t \t \t  "+sks);
     counter++;
   }
}
}

Class Utama :
import javax.swing.JOptionPane;
public class utama {
    public static void main(String[] args)
    { 
    int pilihan;  
    String Mpilihan, menu;
    do
    {
    menu =" 1. Mahasiswa :\n "+" 2. Dosen :\n "+" 3. Mata Kuliah :\n "+" 4. Dosen Mengajar :\n "+" 0. Keluar \n "+"Ketikkan Pilihan Anda :";
    Mpilihan = JOptionPane.showInputDialog(null,menu," Program Pengisian Data ",JOptionPane.QUESTION_MESSAGE);
    pilihan = Integer. parseInt(Mpilihan);
    switch (pilihan)
{   
       case 1:
       mahasiswa coba = new mahasiswa ();
       coba.setnim();
       coba.setNama();
       coba.setAlmat();
       coba.setjeniskelamin();
       coba.setKota();
       coba.setUmur();
       coba.setStrata();
       coba.setJurusan();
       System.out.println(" Pengisian Data Mahasiswa ");
       System.out.println(" --------------");
       System.out.println("Nim           = "+coba.getnim());
       System.out.println("Nama          = "+coba.getNama());
       System.out.println("Alamat        = "+coba.getAlamat());
       System.out.println("Jenis kelamin = "+coba.getjeniskelamin());
       System.out.println("Kota          = "+coba.getKota());
       System.out.println("Umur          = "+coba.getUmur());
       System.out.println("Strata        = "+coba.getStrata());
       System.out.println("Jurusan       = "+coba.getJurusan());
       break;  
       case 2:
       dosen coba1 = new dosen ();
       coba1.setnik();
       coba1.setNama();
       coba1.setAlmat();
       coba1.setjeniskelamin();
       coba1.setKota();
       coba1.setUmur();
       coba1.setfakultas();
       System.out.println(" Pengisian Data Doden ");
       System.out.println(" --------------");
       System.out.println("  ");
       System.out.println("nik           = "+coba1.getnik());
       System.out.println("Nama          = "+coba1.getNama());
       System.out.println("Alamat        = "+coba1.getAlamat());
       System.out.println("Jenis kelamin = "+coba1.getjeniskelamin());
       System.out.println("Kota          = "+coba1.getKota());
       System.out.println("Umur          = "+coba1.getUmur());
       System.out.println("fakultas      = "+coba1.getfakultas());    
       break;
       case 3:
       mata_kuliah coba2 = new mata_kuliah ();
       coba2.setnim();
       coba2.setNama();
       coba2.setJurusan();
       coba2.setStrata();
       System.out.println(" Pengisian Data Mata Kuliah ");
       System.out.println(" -----------------------------------");
       System.out.println("Nim         = "+coba2.getnim());
       System.out.println("Nama        = "+coba2.getNama());
       System.out.println("Jurusan     = "+coba2.getJurusan());
       System.out.println("Strata      = "+coba2.getJurusan());
       System.out.println(" -----------------------------------");
       System.out.println("Mahasiswa Mengambil Mata Kuliah");
       System.out.println("NO  Materi Kuliah  =========>>  SKS");
       coba2.mata_kuliah1();
       break;
       case 4:
       Mengajar coba3 = new Mengajar ();
       coba3.setnik();
       coba3.setNama();
       coba3.setfakultas();
       System.out.println(" Pengisian Data Mengajar ");
       System.out.println(" ----------------------------------");
       System.out.println("  ");
       System.out.println("nik         = "+coba3.getnik());
       System.out.println("Nama        = "+coba3.getNama());
       System.out.println("fakultas    = "+coba3.getfakultas());
       System.out.println(" ----------------------------------");
       System.out.println("Dosen Mengajar Mata Kuliah");
       System.out.println("NO  Materi Kuliah  =========>>  SKS");
       coba3.Mengajar1();
       break;
       case 0 :
       JOptionPane.showMessageDialog(null, "TERIMA KASIH","",JOptionPane.INFORMATION_MESSAGE);
       System.exit(0);                 
       break;                  
       default:                               
       JOptionPane.showMessageDialog(null, "Maaf Pilihanya cuman 0..4 aja","",JOptionPane.WARNING_MESSAGE); 
    }
}
    while(true);
}
}

0 komentar:

Posting Komentar