Commit 96484550 authored by a-j.towse's avatar a-j.towse

Working version with displayEnvironmentList

parent 3dd4a863
No preview for this file type
No preview for this file type
...@@ -40,6 +40,9 @@ public abstract class Animal { ...@@ -40,6 +40,9 @@ public abstract class Animal {
return this.foodType; return this.foodType;
} }
public String getEnvironment(){
return this.environment;
}
} }
...@@ -19,11 +19,15 @@ public class App { ...@@ -19,11 +19,15 @@ public class App {
myZoo.displayfoodRequirements(Rex); myZoo.displayfoodRequirements(Rex);
myZoo.displayfoodRequirements(Pix); myZoo.displayfoodRequirements(Pix);
ArrayList<Animal> animalFoodReqList = new ArrayList<>(); ArrayList<Animal> animalList = new ArrayList<>();
animalFoodReqList.add(Rex); animalList.add(Rex);
animalFoodReqList.add(Pix); animalList.add(Pix);
myZoo.displayfoodListRequirements(animalFoodReqList);
myZoo.displayfoodListRequirements(animalList);
myZoo.displayListDetials(animalList);
myZoo.displayEnvironmentList("house");
} }
} }
......
...@@ -34,4 +34,18 @@ public class Zoo { ...@@ -34,4 +34,18 @@ public class Zoo {
} }
} }
public void displayListDetials(ArrayList<Animal>animalList){
for (int i=0; i < animalList.size();i++){
displayDetails(animalList.get(i));
}
}
public void displayEnvironmentList(String environment){
for (int i=0; i < animalArrayList.size();i++){
if(animalArrayList.get(i).getEnvironment() == environment){
System.out.println(animalArrayList.get(i).name);
}
}
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment