-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEagle.java
57 lines (50 loc) · 1.55 KB
/
Eagle.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
package com.ioannis.unipiZoo;
public class Eagle extends Animal {
public double wingsLength;
private static int counter=0; //static because it has to count the instances of this specific class in order to give different id to each instance
public Eagle(String name, String homotaxy, double weight, int age, double wingsLength) {
super(name, homotaxy, weight, age);
this.wingsLength = wingsLength;
setClassname("eagle");
counter+=1;
if (counter < 100) setId("eag"+00+counter);
else if (counter >= 100) setId("eag"+00+counter);
}
@Override
public double getWingsLength() {
return wingsLength;
}
@Override
public void setWingsLength(double wingsLength) {
this.wingsLength = wingsLength;
}
@Override
public void makeSound()
{
System.out.println("-kra kra kra kra-");
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Override
public void rarity()
{
if (counter<3)
System.out.println("animal is rare in our zoo");
else
System.out.println("animal is common in our zoo");
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@Override
public String toString() {
return super.toString() +
" wings length=" + wingsLength +
'}';
}
}