Database Akademik (Inheritance)
Source Code
2. Matkul
3. Kelas
4.Dosen
5. Buku
6. Pegawai
7. TestDatabase
1. Mahasiswa
/**
* Write a description of class Mahasiswa here.
*
* @author (Lutfiyanti)
* @version (a version number or a date)
*/
public class Mahasiswa extends Database
{
private String jurusan;
private String alamat;
private String agama;
public Mahasiswa (String n, String i, String j, String a1, String a2)
{
super (n,i);
jurusan = j;
alamat = a1;
agama = a2;
}
public String toString()
{
return "Mahasiswa[super=" + super.toString() + ",jurusan=" + jurusan + ",alamat=" + alamat + ",agama=" + agama + "]";
}
}
2. Matkul
/**
* Write a description of class Matkul here.
*
* @author (Lutfiyanti)
* @version (a version number or a date)
*/
public class Matkul extends Database
{
private String semester;
public Matkul (String n, String i, String s)
{
super(n,i);
semester = s;
}
public String toString()
{
return "Matkul[super=" + super.toString() + ",semester=" + semester + "]";
}
}
3. Kelas
/**
* Write a description of class Kelas here.
*
* @author (Lutfiyanti)
* @version (a version number or a date)
*/
public class Kelas extends Database
{
private int totalSiswa;
public Kelas (String n, String i, int t)
{
super (n,i);
totalSiswa = t;
}
public String toString ()
{
return "Kelas[super=" + super.toString() + ",totalSiswa=" + totalSiswa + "]";
}
}
4.Dosen
/**
* Write a description of class Dosen here.
*
* @author (Lutfiyanti)
* @version (a version number or a date)
*/
public class Dosen extends Database
{
private String bidang;
private String alamat;
private String agama;
public Dosen (String n, String i, String b, String a1, String a2)
{
super (n,i);
bidang = b;
alamat = a1;
agama = a2;
}
public String toString()
{
return "Dosen[super=" + super.toString() + ",bidang=" + bidang + ",alamat=" + alamat + ",agama=" + agama + "]";
}
}
5. Buku
/**
* Write a description of class Buku here.
*
* @author (Lutfiyanti)
* @version (a version number or a date)
*/
public class Buku extends Database
{
private String penulis;
private int tahun;
public Buku (String n, String i, String p, int t)
{
super(n,i);
penulis = p;
tahun = t;
}
public String toString()
{
return "Buku[super=" + super.toString() + ",penulis=" + penulis + ",tahun=" + tahun + "]";
}
}
6. Pegawai
/**
* Write a description of class Pegawai here.
*
* @author (Lutfiyanti)
* @version (a version number or a date)
*/
public class Pegawai extends Database
{
private String alamat;
private String agama;
public Pegawai (String n, String i, String a1, String a2)
{
super(n,i);
alamat = a1;
agama = a2;
}
public String toString()
{
return "Pegawai[super=" + super.toString() + ",alamat=" + alamat +",agama=" + agama + "]";
}
}
7. TestDatabase
/**
* Write a description of class TestDatabase here.
*
* @author (Lutfiyanti)
* @version (a version number or a date)
*/
public class TestDatabase
{
public static void main (String[] args)
{
Mahasiswa a1 = new Mahasiswa ("Lutfiy","05111740000036","Informatika","Gebang Wetan","Islam");
Mahasiswa a2 = new Mahasiswa ("Arini P","05111740000040","Informatika","Gebang Wetan","Islam");
Mahasiswa a3 = new Mahasiswa ("Arini Inf","051117400000189","Informatika","Keputih g3","Islam");
Mahasiswa a4 = new Mahasiswa ("Adin","05111740000019","Informatika","Keputih g3 C","Islam");
Mahasiswa a5 = new Mahasiswa ("Chaniy","051117400070118","Informatika","Surabaya","Islam");
Dosen b1 = new Dosen ("Pak Fajar","D0001","Pemrograman Berbasis Objek","Surabaya","Islam");
Dosen b2 = new Dosen ("Pak Arun","D0002","Struktur Data","Surabaya","Kristen");
Dosen b3 = new Dosen ("Bu Sarwo","D0003","Sistem Basis Data","Surabaya","Islam");
Dosen b4 = new Dosen ("Pak Bagus","D0004","Jaringan Komputer","Surabaya","Islam");
Dosen b5 = new Dosen ("Pak Hadziq","D0005","Teori Graf dan Otomata","Surabaya","Islam");
Kelas c1 = new Kelas ("A","K0001",35);
Kelas c2 = new Kelas ("B","K0002",35);
Kelas c3 = new Kelas ("C","K0003",35);
Kelas c4 = new Kelas ("D","K0004",35);
Kelas c5 = new Kelas ("E","K0005",35);
Matkul d1 = new Matkul ("Pemrograman Berbasis Objek","M0001","Tiga");
Matkul d2 = new Matkul ("Stuktur Data","M0002","Tiga");
Matkul d3 = new Matkul ("Sistem Basis Data","M0003","Tiga");
Matkul d4 = new Matkul ("Jaringan Komputer","M0004","Tiga");
Matkul d5 = new Matkul ("Teori Graf dan Otomata","M0005","Tiga");
Pegawai e1 = new Pegawai ("Amin","P0001","Surabaya","Islam");
Pegawai e2 = new Pegawai ("Rudi","P0002","Surabaya","Islam");
Pegawai e3 = new Pegawai ("Siti","P0003","Surabaya","Islam");
Pegawai e4 = new Pegawai ("Ratna","P0004","Surabaya","Islam");
Pegawai e5 = new Pegawai ("Lastri","P0005","Surabaya","Islam");
Buku f1 = new Buku ("Data Structures in C","B0001","Noel Kalicharan",1990);
Buku f2 = new Buku ("Graph Theory With Applications","B0002","C.Vasudev",2006);
Buku f3 = new Buku ("Computer Networking","B0003","Kurose & Ross",2003);
Buku f4 = new Buku ("Object First With Java","B0004","David Barnes",2003);
Buku f5 = new Buku ("Numerical Methods for Engineers","B0005","Steven & Raymond",1998);
System.out.println("===============DATABASE AKADEMIK INFORMARIKA ITS===============");
System.out.println("\n");
System.out.println(" DATABASE MAHASISWA ");
System.out.println(a1);
System.out.println("\n");
System.out.println(" DATABASE DOSEN ");
System.out.println(b1);
System.out.println("\n");
System.out.println(" DATABASE KELAS ");
System.out.println(c1);
System.out.println("\n");
System.out.println(" DATABASE MATA KULIAH ");
System.out.println(d1);
System.out.println("\n");
System.out.println(" DATABASE PEGAWAI ");
System.out.println(e1);
System.out.println("\n");
System.out.println(" DATABASE BUKU ");
System.out.println(f1);
System.out.println("\n");
}
}
Komentar