0% found this document useful (0 votes)
89 views8 pages

Tugas Hewan

The document contains code for three Java classes: TesLatihan, Orang, and Dosen. TesLatihan and Orang define properties like name, age, and NIP and methods to get, set, and print these properties. Dosen is the main class and creates objects of TesLatihan to set properties for three people and print their identities. It also contains code for classes PengambilanUang, Tabungan, and TesTugas dealing with money withdrawal from savings accounts.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
89 views8 pages

Tugas Hewan

The document contains code for three Java classes: TesLatihan, Orang, and Dosen. TesLatihan and Orang define properties like name, age, and NIP and methods to get, set, and print these properties. Dosen is the main class and creates objects of TesLatihan to set properties for three people and print their identities. It also contains code for classes PengambilanUang, Tabungan, and TesTugas dealing with money withdrawal from savings accounts.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8

1.

public class TesLatihan { private String nama ; private int umur, nip ; public String getName(){ return nama; } public void setName( String dosen ){ nama = dosen; } public void setAge( int dosen ){ umur = dosen ; } public void setNip( int dosen ){ nip = dosen; } public void print( String temp ){ System.out.println("Nama :" + nama); System.out.println("Umur :" + umur); System.out.println("NIP :" + nip ); } }

2. public class Orang { private String nama ; private int umur ; public String getName(){ return nama; } public void setName( String dosen ){ nama = dosen; } public void setAge( int dosen ){ umur = dosen; } public void print( String temp ){ System.out.println("Nama :" + nama); System.out.println("Umur :" + umur ); } }

3. public class Dosen { public static void main( String[] args ){ System.out.println("Masukkan identitas dosen 1 : Agus"); System.out.println("Masukkan identitas dosen 2 : Budi, NIP. 1458") ; System.out.println("Masukkan identitas dosen 3 : Iwan, NIP. 1215, umur 47"); TesLatihan AgusData = new TesLatihan(); TesLatihan BudiData = new TesLatihan();

TesLatihan IwanData = new TesLatihan(); AgusData.setName("Agus"); AgusData.setNip(0); AgusData.setAge(0); BudiData.setName("Budi"); BudiData.setNip(1458); BudiData.setAge(0); IwanData.setName("Iwan"); IwanData.setNip(1215); IwanData.setAge(47); System.out.println("\n=== Identitas Dosen1 ==="); AgusData.print( AgusData.getName() ); System.out.println(" ==================== "); System.out.println("=== Identitas Dosen2 ==="); BudiData.print( BudiData.getName() ); System.out.println(" ==================== "); System.out.println("=== Identitas Dosen3 ==="); IwanData.print( IwanData.getName() ); System.out.println(" ==================== "); } }

SYNTAQ BAB 10

1. class PengambilanUang extends Tabungan { private String AmbilUang; public PengambilanUang(String AmbilUang, String Saldo, String Uangditabung, String Uangyangdiproteksi) { super(Saldo,Uangditabung,Uangyangdiproteksi); this.AmbilUang = AmbilUang;

} public void info () { System.out.println("Uang yang diambil : " + this.AmbilUang); super.info(); } }

2. class Tabungan { private String Saldo; private String Uangditabung; private String Uangyangdiproteksi;

public Tabungan(String Saldo, String Uangditabung, String Uangyangdiproteksi) { this.Saldo = Saldo; this.Uangditabung = Uangditabung; this.Uangyangdiproteksi = Uangyangdiproteksi; } public void info () { System.out.println("Uang yang ditabung : " + this.Uangditabung); System.out.println("Uang yang diproteksi : " + this.Uangyangdiproteksi); System.out.println("Saldo : " + this.Saldo); } }

public class TesTugas { 3. public static void main (String args[]) { System.out.println("Uang yang ditabung : 5000"); System.out.println("uang yang diproteksi : 1000"); System.out.println("------------------"); System.out.println("Uang yang akan diambil : 4500 False"); System.out.println("Saldo sekarang : "); System.out.println("------------------"); System.out.println("Uang yang akan diambil : 2500 True" ); System.out.println("Saldo sekarang : " ); } }

TUGAS INDIVIDU
PEMROGRAMAN BERORIENTASI OBJEK

DISUSUN OLEH:

NAMA NIM

:ERWAN EFENDI : 0803020649

PROGRAM STUDI D3 MANAJEMEN INFORMATIKA JURUSAN MATEMATIKA FAKULTAS MATEMATIKA DAN ILMU PENGETAHUAN ALAM UNIVERSITAS RIAU 2010

You might also like