Nama : Zahrul Zizki D
NRP : 05111740000168\
KELAS : PBO - B


Tugas : Database Akademik(Inheritance)
Berikut adalah program untuk Database Akademik




Sourcecode Buku
/**   
  * @author Zahrul Zizki D 
  * @version 1.6/20181119    
  */   
  public class buku   
  {   
   private String judul;   
   private String penulis;   
   public buku(String Buku, String Penulis)   
   {   
    judul = Buku;   
    penulis = Penulis;   
   }   
   public String getBuku()   
   {   
    return judul;   
   }   
  }   

SourceCode Pegawai
import java.util.ArrayList;   
  /**   
  * @author Zahrul Zizki D  
  * @version 1.3/20181119   
  */   
  public class pegawai extends id   
  {   
   private String nid;   
   private ArrayList<buku> Buku;   
   public pegawai(String name, String NID, String address, int age)   
   {   
    super(name, address, age);   
    nid = NID;   
   }   
   public void Pinjam(buku ABuku)   
   {   
    Buku.add(ABuku);   
   }   
   public void Pengembalian(buku ABuku)   
   {   
    Buku.remove(ABuku);   
   }   
   public void print()   
   {   
    System.out.println("NID   : "+ nid);   
    super.print();   
    for(buku BUKU : Buku)   
    {   
     System.out.println("Judul Buku  : "+ BUKU.getBuku());   
    }   
   }   
   public void printd()   
   {   
    System.out.println("NID   : "+ nid);   
    super.print();   
   }   
  }   

Sourcecode Dosen
import java.util.ArrayList;   
  /**   
  * @author Zahrul Zizki D
  * @version 1.2/20181119   
  */   
  public class dosen extends id   
  {   
   private String nip;   
   private ArrayList<buku> Buku;   
   public dosen(String name, String NIP, String address, int age)   
   {   
    super(name, address, age);   
    nip = NIP;   
   }   
   public String getDosen()   
   {   
    return super.getNama();   
   }   
   public void Pinjam(buku ABuku)   
   {   
    Buku.add(ABuku);   
   }   
   public void Pengembalian(buku ABuku)   
   {   
    Buku.remove(ABuku);   
   }   
   public void print()   
   {   
    System.out.println("NIP   : "+ nip);   
    super.print();   
    for(buku BUKU : Buku)   
    {   
     System.out.println("Judul Buku : "+ BUKU.getBuku());   
    }   
   }   
   public void printd()   
   {   
    System.out.println("NIP   : "+ nip);   
    super.print();   
   }   
  }      

SourceCode Id
/**   
  * @author Zahrul Zizki D
  * @version 1.0/20181119   
  */   
  public class id   
  {   
   private String nama;   
   private String alamat;   
   private int umur;   
   public id(String name, String address, int age)   
   {   
    nama = name;   
    alamat = address;   
    umur = age;   
   }   
   public void print()   
   {   
    System.out.println("Nama  :"+ nama);   
    System.out.println("Alamat  :"+ alamat);   
    System.out.println("Umur  :"+ umur);   
   }   
   public String getNama()   
   {   
    return nama;   
   }   
  }   
SourceCode Mahasiswa
import java.util.ArrayList;   
  /**   
  * @author Zahrul Zizki D  
  * @version 1.1/20181119   
  */   
  public class mahasiswa extends id   
  {   
   private String NRP;   
   private ArrayList<matkul> MataKuliah;   
   private ArrayList<buku> Buku;   
   public mahasiswa(String name, String nrp, String address, int age)   
   {   
    super(name, address, age);   
    NRP = nrp;   
    MataKuliah = new ArrayList<matkul>();   
    Buku = new ArrayList<buku>();   
   }   
   public void addMK(matkul Mata_Kuliah)   
   {   
    MataKuliah.add(Mata_Kuliah);   
   }   
   public void dropMK(matkul Mata_Kuliah)   
   {   
    MataKuliah.remove(Mata_Kuliah);   
   }   
   public void MeminjamBuku(buku Books)   
   {   
    Buku.add(Books);   
   }   
   public void PengembalianBuku(buku Books)   
   {   
    Buku.remove(Books);   
   }   
   public void print()   
   {   
    System.out.println("NRP   :" + NRP);   
    super.print();   
    for(matkul matakuliah : MataKuliah)   
    {   
     System.out.println("Mata Kuliah : "+ matakuliah.getMatkul());   
     System.out.println("Kelas  : "+ matakuliah.getKls());   
     System.out.println("Dosen  : "+ matakuliah.getDsn());   
    }   
    for(buku ABooks : Buku)   
    {   
     System.out.println("Judul Buku : "+ ABooks.getBuku());   
    }   
   }   
   public void printd()   
   {   
    System.out.println("NRP   : "+ NRP);   
    super.print();   
   }   
  }   

sourceCode Matakuliah
/**   
  * @author Zahrul Zizki D   
  * @version 1.4/20181119   
  */   
  public class matkul   
  {   
   private int kode;   
   private String mata_kuliah;   
   private int jum_sks;   
   private kelas kels;   
   private String kel;   
   private String dos;   
   public matkul(int Kode, String Mata_Kuliah, int sks)   
   {   
    kode = Kode;   
    mata_kuliah = Mata_Kuliah;   
    jum_sks = sks;   
   }   
   public String getMatkul()   
   {   
    return mata_kuliah;   
   }   
   public void addKelas(kelas AKelas)   
   {   
    kel = AKelas.getKelas();   
   }   
   public String getKls()   
   {   
    return kel;   
   }   
   public void addDosen(dosen Dosen)   
   {   
    dos = Dosen.getDosen();   
   }   
   public String getDsn()   
   {   
    return dos;   
   }   
   public void print()   
   {   
    System.out.println("Kode   : "+ kode);   
    System.out.println("Mata Kuliah : "+ mata_kuliah);   
    System.out.println("SKS   : "+ jum_sks);   
   }   
  }    

SourceCode KElas
/**   
  * @author Zahrul Zizki D  
  * @version 1.5/20181119   
  */   
  public class kelas   
  {   
   private String Kelas;   
   public kelas(String kel)   
   {   
    Kelas = kel;   
   }   
   public String getKelas()   
   {   
    return Kelas;   
   }   
  }     
SourceCode DataBase

import java.util.ArrayList;   
  /**   
  * @author Zahrul Zizki D 
  * @version 1.7/20181119   
  */   
  public class database   
  {   
   private ArrayList<mahasiswa> mhs;   
   private ArrayList<dosen> dos;   
   private ArrayList<pegawai> pgw;   
   public database()   
   {   
    mhs = new ArrayList<mahasiswa>();   
    dos = new ArrayList<dosen>();   
    pgw = new ArrayList<pegawai>();   
   }   
   public void addMahasiswa(mahasiswa Mahasiswa)   
   {   
    mhs.add(Mahasiswa);   
   }   
   public void deleteMahasiswa(mahasiswa Mahasiswa)   
   {   
    mhs.remove(Mahasiswa);   
   }   
   public void addDosen(dosen Dosen)   
   {   
    dos.add(Dosen);   
   }   
   public void deleteDosen(dosen Dosen)   
   {   
    dos.remove(Dosen);   
   }   
   public void addPegawai(pegawai Pegawai)   
   {   
    pgw.add(Pegawai);   
   }   
   public void deletePegawai(pegawai Pegawai)   
   {   
    pgw.remove(Pegawai);   
   }   
   public void listMahasiswa()   
   {   
     System.out.println(" ");  
     System.out.println(" List Mahasiswa ");   
     System.out.println(" ");  
    for(mahasiswa A : mhs)   
    {   
     A.printd();   
     System.out.println();   
    }   
   }   
   public void listDosen()   
   {   
     System.out.println(" ");  
     System.out.println(" Dosen List ");   
     System.out.println(" ");  
    for(dosen A : dos)   
    {   
     A.printd();   
     System.out.println();   
    }   
   }   
   public void listPegawai()   
   {   
     System.out.println(" ");  
     System.out.println(" Employe List");   
     System.out.println(" ");  
    for(pegawai A : pgw)   
    {   
     A.printd();   
     System.out.println();   
    }   
   }   
  }   

Inputkan data mahasiswa, dosen, pegawai, mata kuliah, kelas, buku

BUKU :


Input kelas dan dosen pada matkul
MK yang akan diambil mahasiswa
Buku yang akan dipinjam mahasiswa
Hasil :

Untuk Ke database yaitu
Hasil print dari database


Komentar

Postingan populer dari blog ini

PBO-B fox and rabbit