-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFish.java
More file actions
37 lines (31 loc) · 819 Bytes
/
Fish.java
File metadata and controls
37 lines (31 loc) · 819 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
public class Fish extends Animal{
private int gills;
private int fins;
public Fish(String type, String size, double weight, int gills, int fins) {
super(type, "size", weight);
this.gills = gills;
this.fins = fins;
}
private void moveMuscles(){
System.out.println("Muscles moving");
}
private void moveBackfin(){
System.out.println("Move backfin");
}
@Override
public void move(String speed) {
super.move(speed);
moveMuscles();
if (speed=="fast"){
moveBackfin();
}
System.out.println();
}
@Override
public String toString() {
return "Fish{" +
"gills=" + gills +
", fins=" + fins +
"} " + super.toString();
}
}