import java.util.Scanner;
public class Kampus
{
String
Nama,Matkul,Status,Prodi;
int
nind,nik,npm;
Scanner input =
new Scanner(System.in);
}
//sub kelas ke pertama
class dosen extends Kampus
{
Scanner inputan=
new Scanner(System.in);
public void
inputdosen()
{
System.out.println("Nama :
Auliya Rahmah ");
System.out.println("Npm : 113112706450037 ");
System.out.println("Tugas
Prak.PBO");
System.out.println("---------------------\n
");
System.out.println("
Inheritance Kampus\n ");
System.out.println("---------------------");
System.out.println(" Data
Dosen ");
System.out.println("---------------------");
System.out.print("Nama : ");
Nama = input.nextLine();
System.out.print("Nind :
");
nind =
inputan.nextInt();
System.out.print("Matkul :");
Matkul = input.nextLine();
}
}
//sub kelas ke dua
class karyawan extends Kampus
{
Scanner inputan=
new Scanner(System.in);
public void
inputKaryawan()
{
System.out.println("---------------------");
System.out.println(" Data
Karyawan ");
System.out.println("---------------------");
System.out.print("Nama : ");
Nama = input.nextLine();
System.out.print("Nik :");
nik
= inputan.nextInt();
System.out.print("Status : ");
Status=
input.nextLine();
}
}
//sub kelas ke ketiga
class Mahasiswa extends Kampus
{
Scanner inputan= new Scanner(System.in);
public void
inputMahasiswa()
{
System.out.println("---------------------");
System.out.println(" Data
Mahasiswa ");
System.out.println("---------------------");
System.out.print("Nama
: ");
Nama = input.nextLine();
System.out.print("Npm :");
npm
= inputan.nextInt();
System.out.print("Prodi : ");
Prodi=
input.nextLine();
}
}
//method main;
class demoKampus
{
public static void main(String[] args)
{
dosen
obj = new dosen();
karyawan
obj1= new karyawan();
Mahasiswa
obj2= new Mahasiswa();
obj.inputdosen();
obj1.inputKaryawan();
obj2.inputMahasiswa();
}
}
No comments:
Post a Comment