Commit d7e179f3 authored by Daniel Pearson's avatar Daniel Pearson

Origin

parents
{
"java.project.sourcePaths": ["src"],
"java.project.outputPath": "bin",
"java.project.referencedLibraries": [
"lib/**/*.jar"
]
}
File added
File added
File added
File added
File added
File added
File added
File added
File added
public class Bird extends zoo {
public Bird(String name, String environment, String food, String height, String gender, String type) {
super(name, environment, food, height, gender, type);
}
}
class Eagle extends Bird {
public Eagle(String name, String environment, String food, String height, String gender, String type) {
super(name, environment, food, height, gender, type);
}
}
class Owl extends Bird {
public Owl(String name, String environment, String food, String height, String gender, String type) {
super(name, environment, food, height, gender, type);
}
}
class Parrot extends Bird {
public Parrot(String name, String environment, String food, String height, String gender, String type) {
super(name, environment, food, height, gender, type);
}
}
public class Insect extends zoo {
public Insect(String name, String environment, String food, String height, String gender, String type) {
super(name, environment, food, height, gender, type);
}
}
class Mantis extends Insect {
public Mantis(String name, String environment, String food, String height, String gender, String type) {
super(name, environment, food, height, gender, type);
}
}
class Bee extends Insect {
public Bee(String name, String environment, String food, String height, String gender, String type) {
super(name, environment, food, height, gender, type);
}
}
class Butterfly extends Insect {
public Butterfly(String name, String environment, String food, String height, String gender, String type) {
super(name, environment, food, height, gender, type);
}
}
public class Mammal extends zoo {
public Mammal(String name, String environment, String food, String height, String gender, String type) {
super(name, environment, food, height, gender, type);
}
}
class Elephant extends Mammal {
public Elephant(String name, String environment, String food, String height, String gender, String type) {
super(name, environment, food, height, gender, type);
}
}
class Tiger extends Mammal {
public Tiger(String name, String environment, String food, String height, String gender, String type) {
super(name, environment, food, height, gender, type);
}
}
class Bear extends Mammal {
public Bear(String name, String environment, String food, String height, String gender, String type) {
super(name, environment, food, height, gender, type);
}
}
public class Reptile extends zoo {
public Reptile(String name, String environment, String food, String height, String gender, String type) {
super(name, environment, food, height, gender, type);
}
}
class Snake extends Reptile{
String name;
String environment;
String food;
String height;
String type;
public Snake(String name, String environment, String food, String height, String gender, String type) {
super(name, environment, food, height, gender, type);
}
public void slither(){
System.out.println("<~~~~~~~~");
}
}
class Lizard extends Reptile{
String name;
String environment;
String food;
String height;
String gender;
String type;
public Lizard(String name, String environment, String food, String height, String gender, String type) {
super(name, environment, food, height, gender, type);
}
}
class Gecko extends Reptile{
String name;
String environment;
String food;
String height;
String gender;
String type;
public Gecko(String name, String environment, String food, String height, String gender, String type) {
super(name, environment, food, height, gender, type);
}
}
import java.util.ArrayList;
public class zoo {
String name;
String environment;
String food;
String height;
String gender;
String type;
//ArrayList<zoo> myAnimals = new ArrayList<zoo>();
public zoo(String name, String environment,String food, String height, String gender, String type) {
this.name = name;
this.environment = environment;
this.food = food;
this.height = height;
this.gender = gender;
this.type = type;
}
public static void main(String[] args){
ArrayList<zoo> myAnimals = new ArrayList<zoo>();
ArrayList<zoo> typeOfAnimal = new ArrayList<zoo>();
setArray(myAnimals);
displayAllAnimals(myAnimals);
individualAnimal(myAnimals,"Snake"); //Can select which animals information you want
animalsFromEnvironment(myAnimals,"Jungle"); //Can select the environment
allAnimalsFood(myAnimals);
arrayListAnimalType(typeOfAnimal, "Bird");
}
public static void setArray(ArrayList<zoo> myAnimals){
Snake Slithers = new Snake("Slithers","Sand","Mice","200cm","M","Snake");
Lizard Ellie = new Lizard("Ed", "Sand", "Mealworms", "10cm", "F","Lizard");
Gecko Charlie = new Gecko("Charlie", "Sand", "Crickets", "20cm", "M","Gecko");
Elephant Bob = new Elephant("Bob", "Jungle", "Leaves", "289cm", "M","Elephant");
Tiger Rory = new Tiger("Rory", "Jungle", "Deers", "177cm", "M","Tiger");
Bear Beth = new Bear("Beth", "Jungle", "Berries", "153cm", "F","Bear");
Mantis Molly = new Mantis("Molly", "Plants", "Beetles", "11cm", "F","Mantis");
Bee Barry = new Bee("Barry", "Plants", "Nectar", "3cm", "M","Bee");
Butterfly Belle = new Butterfly("Belle", "Plants", "Fruit", "8cm", "F","Butterfly");
Eagle Emma = new Eagle("Emma", "Field", "Rabbits", "90cm", "F","Eagle");
Owl Oscar = new Owl("Oscar", "Field", "Snails", "40cm", "M","Owl");
Parrot Peter = new Parrot("Peter", "Field", "Seeds", "50cm", "M","Parrot");
myAnimals.add(Slithers);
myAnimals.add(Ellie);
myAnimals.add(Charlie);
myAnimals.add(Bob);
myAnimals.add(Rory);
myAnimals.add(Beth);
myAnimals.add(Molly);
myAnimals.add(Barry);
myAnimals.add(Belle);
myAnimals.add(Emma);
myAnimals.add(Oscar);
myAnimals.add(Peter);
}
public static void displayAllAnimals(ArrayList<zoo> myAnimals) { //Displays all animals that are in the zoo
int size = myAnimals.size();
for(int i =0;i < size; i++){
System.out.println("Animal type: "+myAnimals.get(i).type+"\n"+"Name: "+myAnimals.get(i).name+"\n" +"Environment: "+myAnimals.get(i).environment+"\n"+"Food: "+myAnimals.get(i).food+
"\n"+"Height: "+myAnimals.get(i).height+"\n"+"Gender: "+myAnimals.get(i).gender +"\n"+"\n");
}
}
public static void individualAnimal(ArrayList<zoo> myAnimals, String animal){
int size = myAnimals.size();
for(int i =0;i < size; i++){
String animal1 = myAnimals.get(i).type;
if(animal1 == animal){
System.out.println("\n"+"\n"+"Animal type: "+animal +"\n"+"Name: "+myAnimals.get(i).name+"\n" +"Environment: "+myAnimals.get(i).environment+"\n"+"Food: "+myAnimals.get(i).food+
"\n"+"Height: "+myAnimals.get(i).height+"\n"+"Gender: "+myAnimals.get(i).gender);
}
}
}
public static void allAnimalsFood(ArrayList<zoo> myAnimals){
int size = myAnimals.size();
for(int i = 0;i < size; i++){
System.out.println("\n"+"\n"+"Animal Type: "+myAnimals.get(i).type+"\n" +"Name: "+myAnimals.get(i).name +"\n"+"Food: "+myAnimals.get(i).food);
}
}
public static void arrayListAnimalType(ArrayList<zoo> typeOfAnimal, String Type){
if(Type == "Reptile"){
Snake Slithers = new Snake("Slithers","Sand","Mice","200cm","M","Snake");
Lizard Ellie = new Lizard("Ed", "Sand", "Mealworms", "10cm", "F","Lizard");
Gecko Charlie = new Gecko("Charlie", "Sand", "Crickets", "20cm", "M","Gecko");
typeOfAnimal.add(Slithers);
typeOfAnimal.add(Ellie);
typeOfAnimal.add(Charlie);
}else if(Type == "Mammal"){
Elephant Bob = new Elephant("Bob", "Jungle", "Leaves", "289cm", "M","Elephant");
Tiger Rory = new Tiger("Rory", "Jungle", "Deers", "177cm", "M","Tiger");
Bear Beth = new Bear("Beth", "Jungle", "Berries", "153cm", "F","Bear");
typeOfAnimal.add(Bob);
typeOfAnimal.add(Rory);
typeOfAnimal.add(Beth);
}else if(Type == "Insect"){
Mantis Molly = new Mantis("Molly", "Plants", "Beetles", "11cm", "F","Mantis");
Bee Barry = new Bee("Barry", "Plants", "Nectar", "3cm", "M","Bee");
Butterfly Belle = new Butterfly("Belle", "Plants", "Fruit", "8cm", "F","Butterfly");
typeOfAnimal.add(Molly);
typeOfAnimal.add(Barry);
typeOfAnimal.add(Belle);
}else if(Type == "Bird"){
Eagle Emma = new Eagle("Emma", "Field", "Rabbits", "90cm", "F","Eagle");
Owl Oscar = new Owl("Oscar", "Field", "Snails", "40cm", "M","Owl");
Parrot Peter = new Parrot("Peter", "Field", "Seeds", "50cm", "M","Parrot");
typeOfAnimal.add(Emma);
typeOfAnimal.add(Oscar);
typeOfAnimal.add(Peter);
}
System.out.println(typeOfAnimal);
}
public static void animalsFromEnvironment(ArrayList<zoo> myAnimals, String environment){
int size = myAnimals.size();
for(int i =0;i < size; i++){
String environment1 = myAnimals.get(i).environment;
if(environment1 == environment){
System.out.println("\n"+"\n"+"Environment: "+environment +"\n" +"Animal Type: "+myAnimals.get(i).type+"\n" +"Name: "+myAnimals.get(i).name) ;
}
}
}
}
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