forked from yfain/Java4Kids_code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFishTank.java
More file actions
31 lines (22 loc) · 701 Bytes
/
Copy pathFishTank.java
File metadata and controls
31 lines (22 loc) · 701 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
package pets;
/**
* Created by NewProgrammer on 3/28/15.
*/
import java.util.ArrayList;
public class FishTank {
public static void main(String[] args) {
ArrayList fishTank = new ArrayList();
Fish fish1 = new Fish(2.5f, "Red");
Fish fish2 = new Fish(5, "Green");
Fish theFish;
fishTank.add(fish1);
fishTank.add(fish2);
int fishCount = fishTank.size();
for (int i=0;i<fishCount; i++){
theFish = (Fish) fishTank.get(i); // casting
System.out.println("Got the " +
theFish.getColor() + " fish that weighs " +
theFish.getWeight() + " pounds.");
}
}
}