forked from yfain/Java4Kids_code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFish.java
More file actions
27 lines (23 loc) · 745 Bytes
/
Copy pathFish.java
File metadata and controls
27 lines (23 loc) · 745 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
/**
* Created by NewProgrammer on 3/28/15.
*/
public class Fish extends Pet {
int currentDepth=0;
public int dive(int howDeep){
currentDepth=currentDepth + howDeep;
if (currentDepth > 100){
System.out.println("I'm just a little fish and "
+ " I can't dive below 100 feet");
currentDepth=currentDepth - howDeep;
}else{
System.out.println("Diving for " + howDeep +
" feet");
System.out.println("I'm at " + currentDepth +
" feet below sea level");
}
return currentDepth;
}
public String say(String something){
return "Hey, don't you know that fish don't talk?";
}
}