-
Notifications
You must be signed in to change notification settings - Fork 0
/
Aldhiyawaris2.java
190 lines (144 loc) · 3.15 KB
/
Aldhiyawaris2.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/**
* @(#)Aldhiyawaris2.java
*
*
* @author
* @version 1.00 2017/8/31
*/
class hewan
{
String nama;
String makanan;
String tempat;
void makan()
{
System.out.println("Sedang makan");
}
void tidur()
{
System.out.println("Sedang tidur");
}
public void PrintData()
{
System.out.println("Nama = "+nama);
System.out.println("Makanan = "+makanan);
System.out.println("Tempat = "+tempat);
}
}
class ikan extends hewan
{
void berenang()
{
System.out.println("Sedang berenang");
}
}
class lumba extends ikan
{
void menari()
{
System.out.println("Sedang Menari");
}
}
class burung extends hewan
{
void terbang()
{
System.out.println("Sedang terbang");
}
}
class singa extends hewan
{
void mengaum()
{
System.out.println("Sedang mengaum");
}
}
class beo extends burung
{
void menyanyi()
{
System.out.println("Sedang menyanyi");
}
}
class merpati extends burung
{
void mengirim()
{
System.out.println("Sedang mengirim surat");
}
}
public class Aldhiyawaris2 {
public static void main (String[] args) {
//pembuatan objek hewan
hewan hewan1 = new hewan();
hewan1.nama = "Jenis Hewan";
hewan1.makanan = "Jenis Makanan";
hewan1.tempat = "Jenis Tempat";
System.out.println("Objek hewan1 -->");
hewan1.PrintData();
hewan1.makan();
hewan1.tidur();
System.out.println("");
//pembuatan objek ikan
ikan ikan1 = new ikan();
ikan1.nama = "Jenis Ikan";
ikan1.makanan = "Jenis Makanan Ikan";
ikan1.tempat = "Laut";
ikan1.PrintData();
ikan1.makan();
ikan1.tidur();
ikan1.berenang();
System.out.println("");
//pembuatan objek lumba
lumba lumba1 = new lumba();
lumba1.nama = "Dolphin";
lumba1.makanan = "Rumput Laut";
lumba1.tempat = "Laut";
lumba1.PrintData();
lumba1.makan();
lumba1.tidur();
lumba1.berenang();
lumba1.menari();
System.out.println("");
//pembuatan objek burung
burung burung1 = new burung();
burung1.nama = "Jenis Burung";
burung1.makanan = "Jenis Makanan Burung";
burung1.tempat = "Udara";
burung1.PrintData();
burung1.makan();
burung1.tidur();
burung1.terbang();
System.out.println("");
//pembuatan objek beo
beo beo1 = new beo();
beo1.nama = "Icha";
beo1.makanan = "Biji-Bijian";
beo1.tempat = "Udara";
beo1.PrintData();
beo1.makan();
beo1.tidur();
beo1.terbang();
beo1.menyanyi();
System.out.println("");
//pembuatan objek merpati
merpati merpati1 = new merpati();
merpati1.nama = "Dina";
merpati1.makanan = "Biji-Bijian";
merpati1.tempat = "Udara";
merpati1.PrintData();
merpati1.tidur();
merpati1.terbang();
merpati1.mengirim();
System.out.println("");
//pembuatan objek singa
singa singa1 = new singa();
singa1.nama = "Leon";
singa1.makanan = "Daging";
singa1.tempat = "Darat";
singa1.PrintData();
singa1.makan();
singa1.tidur();
singa1.mengaum();
}
}