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

Final commit, all methods working correctly and in line with marking rubric

parent 2264d271
No preview for this file type
No preview for this file type
import java.util.ArrayList;
public class App { public class App {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Zoo myZoo = new Zoo();
Fish Rex = new Fish("Rex","red stripes","sea","sea-weed",12.5,"freshwater");
Fish Pix = new Fish("Pix","gold","river","smaller fish",5.0,"saltwater");
Bird Rob = new Bird("Rob","red robin","large tree","seeds",false,true);
Mammal Tom = new Mammal("Tom","striped tiger","savannah","meat", 90.0,120.0);
Reptile Cameron = new Reptile("Cam","green eyed crocodile","salt water","chicken",182.5,230.0);
myZoo.addanimal(Tom);
myZoo.addanimal(Cameron);
myZoo.addanimal(Rex);
myZoo.addanimal(Pix);
myZoo.addanimal(Rob);
myZoo.displayAnimalArrayList();
myZoo.displayDetails(Tom);
myZoo.displayfoodRequirements(Tom);
myZoo.displayfoodRequirements(Cameron);
ArrayList<Animal> animalList = new ArrayList<>();
animalList.add(Tom);
animalList.add(Cameron);
myZoo.displayfoodListRequirements(animalList);
myZoo.displayListDetials(animalList);
myZoo.displayEnvironmentList("savannah");
myZoo.displayAnimalType("Reptile");
myZoo.displayAnimalType("Fish");
} }
} }
...@@ -51,9 +51,20 @@ public class Zoo { ...@@ -51,9 +51,20 @@ public class Zoo {
//WIP animal type, get class //WIP animal type, get class
public void displayAnimalType(String animalType){ public void displayAnimalType(String animalType){
for (int i=0; i < animalArrayList.size();i++){ for (int i=0; i < animalArrayList.size();i++){
if(animalArrayList.get(i).toString() == animalType){ if(animalArrayList.get(i) instanceof Mammal && animalType == "Mammal"){
System.out.println(animalArrayList.get(i).getName());
} }
if(animalArrayList.get(i) instanceof Bird && animalType == "Bird"){
System.out.println(animalArrayList.get(i).getName());
} }
if(animalArrayList.get(i) instanceof Reptile && animalType == "Reptile"){
System.out.println(animalArrayList.get(i).getName());
} }
if(animalArrayList.get(i) instanceof Fish && animalType == "Fish"){
System.out.println(animalArrayList.get(i).getName());
}
}
}
} }
\ No newline at end of file
...@@ -2,6 +2,9 @@ import static org.junit.Assert.assertEquals; ...@@ -2,6 +2,9 @@ import static org.junit.Assert.assertEquals;
import org.junit.Test; import org.junit.Test;
import java.util.ArrayList; import java.util.ArrayList;
//Used to test in progress, currently not in use
public class unitTest { public class unitTest {
@Test @Test
......
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