Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package profil;
- //Profil.java
- public class Profil
- {
- String nama;
- int umur;
- double gaji;
- String alamat;
- public Profil(String nama, int umur, double gaji, String alamat)
- {
- this.nama = nama;
- this.umur = umur;
- this.gaji = gaji;
- this.alamat = alamat;
- }
- public String getNama()
- {
- return nama;
- }
- public int getUmur()
- {
- return umur;
- }
- public double getGaji()
- {
- return gaji;
- }
- public String getAlamat()
- {
- return alamat;
- }
- public void setNama(String nama)
- {
- this.nama = nama;
- }
- public void setUmur(int umur)
- {
- this.umur = umur;
- }
- public void setGaji(double gaji)
- {
- this.gaji = gaji;
- }
- public void setAlamat(String alamat)
- {
- this.alamat = alamat;
- }
- }
- //ProfilBaru.java
- package profil;
- public class ProfilBaru extends Profil
- {
- public ProfilBaru(String nama, int umur, double gaji, String alamat)
- {
- super(nama, umur, gaji, alamat);
- }
- @Override
- public String getNama()
- {
- return nama;
- }
- @Override
- public int getUmur()
- {
- return umur;
- }
- @Override
- public double getGaji()
- {
- return gaji;
- }
- @Override
- public String getAlamat()
- {
- return alamat;
- }
- }
- //ProfilImplentasi.java
- package profil;
- import java.io.*;
- public class ProfilImplementasi
- {
- static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- static String nama;
- static int umur;
- static double gaji;
- static String alamat;
- public static void main(String[]args) throws IOException
- {
- buatProfil();
- Profil profil = new Profil(nama, umur, gaji, alamat);
- System.out.println("\n" + profil.getNama() + "\n" + profil.getUmur() + "\n" + profil.getGaji() + "\n" + profil.getAlamat());
- System.out.println("--- Buat Profil Baru ---");
- buatProfil();
- ProfilBaru profilBaru = new ProfilBaru(nama, umur, gaji, alamat);
- System.out.println("\n" + profilBaru.getNama() + "\n" + profilBaru.getUmur() + "\n" + profilBaru.getGaji() + "\n" + profilBaru.getAlamat());
- }
- public static void buatProfil() throws IOException
- {
- nama = reader.readLine();
- umur = Integer.parseInt(reader.readLine());
- gaji = Double.parseDouble(reader.readLine());
- alamat = reader.readLine();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement