Commit 2264d271 authored by a-j.towse's avatar a-j.towse

WIP displayAnimalType

parent 292c1928
No preview for this file type
No preview for this file type
...@@ -35,7 +35,6 @@ public abstract class Animal { ...@@ -35,7 +35,6 @@ public abstract class Animal {
detailList.add(detail1); detailList.add(detail1);
} }
public String getFoodType(){ public String getFoodType(){
return this.foodType; return this.foodType;
} }
......
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 {
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 Fred = new Bird("Fred","pink feathers","savannah", "shrimp",false,true);
myZoo.addanimal(Rex);
myZoo.addanimal(Pix);
myZoo.addanimal(Fred);
myZoo.displayAnimalArrayList();
myZoo.displayDetails(Rex);
myZoo.displayfoodRequirements(Rex);
myZoo.displayfoodRequirements(Fred);
ArrayList<Animal> animalList = new ArrayList<>();
animalList.add(Rex);
animalList.add(Pix);
myZoo.displayfoodListRequirements(animalList);
myZoo.displayListDetials(animalList);
myZoo.displayEnvironmentList("savannah");
}
} }
}
...@@ -48,4 +48,12 @@ public class Zoo { ...@@ -48,4 +48,12 @@ public class Zoo {
} }
} }
//WIP animal type, get class
public void displayAnimalType(String animalType){
for (int i=0; i < animalArrayList.size();i++){
if(animalArrayList.get(i).toString() == animalType){
}
}
}
} }
\ No newline at end of file
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import org.junit.Test; import org.junit.Test;
import java.util.ArrayList;
public class unitTest { public class unitTest {
@Test @Test
public void testConstructors(){ public void testConstructors(){
//Fish Constructor
Fish Rex = new Fish("Rex","red stripes","sea","sea-weed",12.5,"freshwater"); 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"); Fish Pix = new Fish("Pix","gold","river","smaller fish",5.0,"saltwater");
Bird Rob = new Bird("Rob","red robin","large tree","seeds",false,true); Bird Rob = new Bird("Rob","red robin","large tree","seeds",false,true);
...@@ -19,4 +19,34 @@ public class unitTest { ...@@ -19,4 +19,34 @@ public class unitTest {
assertEquals("Tom", Tom.getName()); assertEquals("Tom", Tom.getName());
assertEquals("green eyed crocodile", Cameron.getDescription()); assertEquals("green eyed crocodile", Cameron.getDescription());
} }
@Test
public void testArrayList(){
Zoo myZoo = new Zoo();
Mammal Tom = new Mammal("Tom","striped tiger","jungle","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.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");
}
} }
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