-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimal.java
More file actions
62 lines (52 loc) · 1.55 KB
/
Animal.java
File metadata and controls
62 lines (52 loc) · 1.55 KB
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
package lesson1.maraphon;
public class Animal implements Competitor {
String type;
String name;
int maxRunDistance;
int maxSwimDistance;
int maxJumpHeigth;
boolean onDistance;
public Animal(String type, String name, int maxRunDistance, int maxSwimDistance, int maxJumpHeigth) {
this.type = type;
this.name = name;
this.maxRunDistance = maxRunDistance;
this.maxSwimDistance = maxSwimDistance;
this.maxJumpHeigth = maxJumpHeigth;
this.onDistance = true;
}
@Override
public void run(int dist) {
if (dist <= maxRunDistance){
System.out.println(type + " " +name+ " успешно пробежал");
}else {
System.out.println("провал");
onDistance = false;
}
}
@Override
public void swim(int dist) {
if (dist <= maxRunDistance){
System.out.println(type + " " +name+ " успешно проплыл");
}else {
System.out.println("провал");
onDistance = false;
}
}
@Override
public void jump(int heigth) {
if (heigth <= maxRunDistance){
System.out.println(type + " " +name+ " успешно перепрыгнул");
}else {
System.out.println("провал");
onDistance = false;
}
}
@Override
public boolean isDistance() {
return onDistance;
}
@Override
public void info() {
System.out.println(type + " " +name+ " "+ onDistance);
}
}