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 {
return this.foodType;
}
public String getEnvironment(){
return this.environment;
}
}
......@@ -19,11 +19,15 @@ public class App {
myZoo.displayfoodRequirements(Rex);
myZoo.displayfoodRequirements(Pix);
ArrayList<Animal> animalFoodReqList = new ArrayList<>();
animalFoodReqList.add(Rex);
animalFoodReqList.add(Pix);
myZoo.displayfoodListRequirements(animalFoodReqList);
ArrayList<Animal> animalList = new ArrayList<>();
animalList.add(Rex);
animalList.add(Pix);
myZoo.displayfoodListRequirements(animalList);
myZoo.displayListDetials(animalList);
myZoo.displayEnvironmentList("house");
}
}
......
......@@ -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