-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCat.java
More file actions
38 lines (34 loc) · 951 Bytes
/
Copy pathCat.java
File metadata and controls
38 lines (34 loc) · 951 Bytes
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
public class Cat extends Animals {
Cat(String name,int age, int weight){
super(name, age, weight);
}
@Override
protected int SetJumpMax() {
int age=GetAge();
int weight=GetWeight();
int jumpMax=2;
if (age>1&&age<8) jumpMax+=3;
else if (age>8&&age<12)jumpMax+=1;
if (weight<1||weight>15) jumpMax-=1;
return jumpMax;
}
@Override
protected int SetRunMax() {
int age=GetAge();
int weight=GetWeight();
int runMax=200;
if (age>1&&age<8) runMax+=100;
else if (age>8&&age<12)runMax+=50;
if (weight<1||weight>15) runMax-=100;
return runMax;
}
@Override
protected int SetSwimMax() {
return 0;
}
@Override
public boolean Swim(int distance) {
System.out.println(GetName()+" не поплывет. Коты не умеют плавать!");
return false;
}
}