id.java:
public class id{
private String nama;
private String alamat;
private int umur;
public id(String var1, String var2, int var3){
nama=var1;
alamat=var2;
umur=var3;
}
public void print(){
System.out.println("Nama:"+nama);
System.out.println("Alamat:"+alamat);
System.out.println("Umur:"+umur);
}
public String getNama(){
return nama;
}
public String getAlamat(){
return alamat;
}
}
mahasiswa.java:
import java.util.ArrayList;
public class mahasiswa extends id{
private String NRP;
private ArrayList<makul> m_k;
private ArrayList<buku> bk;
public mahasiswa(String var1, String varNRP, String var2, int var3){
super(var1, var2, var3);
NRP = varNRP;
m_k = new ArrayList<makul>();
bk = new ArrayList<buku>();
}
public void addMK(makul varMK){
m_k.add(varMK);
}
public void dropMK(makul varMK){
m_k.remove(varMK);
}
public void MeminjamBuku(buku varBuku){
bk.add(varBuku);
}
public void PengembalianBuku(buku varBuku)
{
bk.remove(varBuku);
}
public void print(){
System.out.println("NRP:"+NRP);
super.print();
for(makul matakuliah : m_k){
System.out.println("Mata Kuliah: "+matakuliah.getMakul());
System.out.println("Kelas: "+matakuliah.getKls());
System.out.println("Dosen: "+matakuliah.getDsn());
}
for(buku BUKU : bk){
System.out.println("Judul buku: "+ BUKU.getBuku());
}
}
public void printd(){
System.out.println("NRP:"+NRP);
super.print();
}
}
dosen.java
import java.util.ArrayList;
public class dosen extends id{
private String NIP;
private ArrayList<buku> bk;
public dosen(String var1, String varNIP, String varAlamat, int varUmur){
super(var1, varAlamat, varUmur);
NIP=varNIP;
}
public String getNIP()
{
return NIP;
}
public String getDosen()
{
return super.getNama();
}
public void MeminjamBuku(buku theBuku)
{
bk.add(theBuku);
}
public void PengembalianBuku(buku theBuku)
{
bk.remove(theBuku);
}
public void print()
{
System.out.println("NIP:" + NIP);
super.print();
for(buku BUKU : bk)
{
System.out.println("Judul Buku: "+ BUKU.getBuku());
}
}
public void printd()
{
System.out.println("NIP:" + NIP);
super.print();
}
}
pegawai.java
import java.util.ArrayList;
public class pegawai extends id
{
private String NID;
private ArrayList<buku> bk;
public pegawai(String varNama, String varNID, String varAlamat, int varUmur)
{
super(varNama, varAlamat, varUmur);
NID = varNID;
}
public String getNID()
{
return NID;
}
public void MeminjamBuku(buku theBuku)
{
bk.add(theBuku);
}
public void PengembalianBuku(buku theBuku)
{
bk.remove(theBuku);
}
public void print()
{
System.out.println("NID:" + NID);
super.print();
for(buku BUKU : bk)
{
System.out.println("Judul Buku: "+ BUKU.getBuku());
}
}
public void printd()
{
System.out.println("NID:" + NID);
super.print();
}
}
kelas.java
public class kelas
{
private String ruang;
public kelas(String kRuang)
{
ruang = kRuang;
}
public String getKelas()
{
return ruang;
}
}</pre>
<br />
<pre>public class buku
{
private String judul;
private String penulis;
public buku(String bBuku, String pPenulis)
{
judul = bBuku;
penulis = pPenulis;
}
public String getBuku()
{
return judul;
}
}
makul.java
public class makul
{
private int kode;
private String mata_kuliah;
private int jum_sks;
private kelas kls;
private String kl;
private String ds;
public makul(int kd, String mk, int sks)
{
kode = kd;
mata_kuliah = mk;
jum_sks = sks;
}
public String getMakul()
{
return mata_kuliah;
}
public void addKelas(kelas KLS)
{
kl = KLS.getKelas();
}
public String getKls()
{
return kl;
}
public void addDosen(dosen dsn)
{
ds = dsn.getDosen();
}
public String getDsn()
{
return ds;
}
public void print()
{
System.out.println("Kode:" + kode);
System.out.println("Mata Kuliah:" + mata_kuliah);
System.out.println("SKS:" + jum_sks);
}
}
database.java
import java.util.ArrayList;
public class database
{
private ArrayList<mahasiswa> mhs;
private ArrayList<dosen> dsn;
private ArrayList<pegawai> peg;
private ArrayList<buku> bkk;
private ArrayList<makul> mku;
public database()
{
mhs = new ArrayList<mahasiswa>();
dsn = new ArrayList<dosen>();
peg = new ArrayList<pegawai>();
bkk = new ArrayList<buku>();
mku = new ArrayList<makul>();
}
public void addMahasiswa(mahasiswa theMhs)
{
mhs.add(theMhs);
}
public void deleteMahasiswa(mahasiswa theMhs)
{
mhs.remove(theMhs);
}
public void addDosen(dosen theDsn)
{
dsn.add(theDsn);
}
public void deleteDosen(dosen theDsn)
{
dsn.remove(theDsn);
}
public void addPegawai(pegawai thePeg)
{
peg.add(thePeg);
}
public void deletePegawai(pegawai thePeg)
{
peg.remove(thePeg);
}
public void addMakul(makul theMku)
{
mku.add(theMku);
}
public void deleteMakul(makul theMku)
{
mku.remove(theMku);
}
public void addBuku(buku theBkk)
{
bkk.add(theBkk);
}
public void deleteBuku(buku theBkk)
{
bkk.remove(theBkk);
}
public void listMahasiswa()
{
for(mahasiswa m : mhs)
{
System.out.println("=========List Mahasiswa=========");
m.printd();
System.out.println();
}
}
public void listDosen()
{
for(dosen d : dsn)
{
System.out.println("=========List Dosen=========");
d.printd();
System.out.println();
}
}
public void listPegawai()
{
for(pegawai p : peg)
{
System.out.println("=========List Pegawai=========");
p.printd();
System.out.println();
}
}
public void listMakul()
{
for(makul a : mku)
{
System.out.println("=========List Makul=========");
a.print();
System.out.println();
}
}
public void listBuku()
{
for(buku b : bkk)
{
System.out.println("=========List Buku=========");
b.print();
System.out.println();
}
}
}
Screenshot:
Note: Seharusnya List Buku (sudah diralat di sourcecode atas)
Komentar
Posting Komentar