TUGAS PBO B - SISTEM AKADEMIK
Dalam sistem akademik saya membuat 8 kelas diantaranya adalah :
1. Database
2. Objek
3. Mahasiswa
4. Dosen
5. Kelas
6. Buku
7. Pegawai
8. Matkul
Berikut source codenya :
1. Database
/**
* Yasinta Yusniawati
* 05111740000054
* PBO-B (18-nov-18)
*/
import java.util.ArrayList;
public class database
{
private ArrayList<pegawai> pgw;
private ArrayList<dosen> dsn;
private ArrayList<mahasiswa> mhs;
private ArrayList<kelas> kls;
private ArrayList<matkul> mk;
private ArrayList<buku> buku;
public database(){
pgw= new ArrayList<pegawai>();
dsn= new ArrayList<dosen>();
mhs= new ArrayList<mahasiswa>();
kls= new ArrayList<kelas>();
mk= new ArrayList<matkul>();
buku= new ArrayList<buku>();
}
public void addpgw (pegawai the_pgw){
pgw.add(the_pgw);
}
public void adddsn (dosen the_dsn){
dsn.add(the_dsn);
}
public void addmhs (mahasiswa the_mhs){
mhs.add(the_mhs);
}
public void addkls (kelas the_kls){
kls.add(the_kls);
}
public void addmk (matkul the_mk){
mk.add(the_mk);
}
public void addbuku (buku the_buku){
buku.add(the_buku);
}
public void list(int id){
int no = 1;
switch(id){
case 1:
for(pegawai cd: pgw){
System.out.println(no++);
for(pegawai iterasi : pgw){
iterasi.print();
}
}
break;
case 2:
for(dosen cd: dsn){
System.out.println(no++);
for(dosen iterasi : dsn){
iterasi.print();
}
}
break;
case 3:
for(mahasiswa cd: mhs){
System.out.println(no++);
for(mahasiswa iterasi : mhs){
iterasi.print();
}
}
break;
case 4:
for(matkul cd: mk){
System.out.println(no++);
for(matkul iterasi : mk){
iterasi.print();
}
}
break;
case 5:
for(kelas cd: kls){
System.out.println(no++);
for(kelas iterasi : kls){
iterasi.print();
}
}
break;
case 6:
for(buku cd: buku){
System.out.println(no++);
}
break;
}
}
}
2. Objek
/**
* Yasinta Yusniawati
* 05111740000054
* PBO-B (18-nov-18)
*/
public class objek
{
private String nama;
private int id;
public objek(String name,int kode)
{
nama = name;
id = kode;
}
public String getnama(){
return nama;
}
public int getid(){
return id;
}
}
3. Mahasiswa
/**
* Yasinta Yusniawati
* 05111740000054
* PBO-B (18-nov-18)
*/
public class mahasiswa extends objek
{
private String degree;
private String address;
public mahasiswa (String name, int kode, String derajat, String alamat)
{
super (name, kode);
degree = derajat;
address = alamat;
}
public String get_degree()
{
return degree;
}
public String get_address()
{
return address;
}
public void print(){
System.out.println("Nama : "+this.getnama());
System.out.println("Kode : "+this.getid());
System.out.println("Derajat : "+this.get_degree());
System.out.println("Alamat : "+this.get_address());
}
}
4. Dosen
/**
* Yasinta Yusniawati
* 05111740000054
* PBO-B (18-nov-18)
*/
public class dosen extends objek
{
private int gaji;
private String jabatan;
public dosen (String name, int kode, int Gaji, String Jabatan)
{
super(name, kode);
gaji = Gaji;
jabatan = Jabatan;
}
public int getgaji()
{
return gaji;
}
public String getjabatan()
{
return jabatan;
}
public void print(){
System.out.println("Nama : "+this.getnama());
System.out.println("Kode : "+this.getid());
System.out.println("Gaji : "+this.getgaji());
System.out.println("Jabatan : "+this.getjabatan());
}
}
5. Kelas
/**
* Yasinta Yusniawati
* 05111740000054
* PBO-B (18-nov-18)
*/
public class kelas extends objek
{
private String ruangan;
public kelas (String name, int kode, String Ruangan)
{
super(name, kode);
ruangan = Ruangan;
}
public String get_ruangan()
{
return ruangan;
}
public void print(){
System.out.println("Nama : "+this.getnama());
System.out.println("Kode : "+this.getid());
System.out.println("Ruangan : "+this.get_ruangan());
}
}
6. Buku
/**
* Yasinta Yusniawati
* 05111740000054
* PBO-B (18-nov-18)
*/
public class buku extends objek
{
private String pengarang;
private int halaman;
public buku (String name, int kode, String Pengarang, int Halaman)
{
super(name, kode);
pengarang = Pengarang;
}
public String get_pengarang()
{
return pengarang;
}
public int get_halaman()
{
return halaman;
}
public void print(){
System.out.println("Nama : "+this.getnama());
System.out.println("Kode : "+this.getid());
System.out.println("Pengarang : "+this.get_pengarang());
System.out.println("Halaman : "+this.get_halaman());
}
}
7. Pegawai
/**
* Yasinta Yusniawati
* 05111740000054
* PBO-B (18-nov-18)
*/
public class pegawai extends objek
{
private String bagian;
public pegawai (String name, int kode, String Bagian)
{
super(name, kode);
bagian = Bagian;
}
public String get_bagian()
{
return bagian;
}
public void print(){
System.out.println("Nama : "+this.getnama());
System.out.println("Kode : "+this.getid());
System.out.println("Bagian : "+this.get_bagian());
}
}
8. Matkul
/**
* Yasinta Yusniawati
* 05111740000054
* PBO-B (18-nov-18)
*/
public class matkul extends objek
{
private String dosen;
public matkul(String name, int kode, String Dosen)
{
super(name, kode);
dosen = Dosen;
}
public String get_dosen()
{
return dosen;
}
public void print(){
System.out.println("Nama : "+this.getnama());
System.out.println("Kode : "+this.getid());
System.out.println("Dosen : "+this.get_dosen());
}
}
Hasil Run nya adalah sebagai berikut :
- Run kelas mahasiswa
- Run kelas dosen
- Run kelas (kelas)
- Run kelas buku
- Run kelas pegawai
- Run kelas matkul
Berikut adalah contoh output pada class matkul
Tidak ada komentar:
Posting Komentar