Commit a9db669b authored by lui.bingham's avatar lui.bingham

Zoo Application

parents
public class Animal extends AnimalType {
String name;
String animaldesc;
}
public class AnimalType {
String animal;
String desc;
String type;
String food;
String environment;
}
import java.util.ArrayList;
import java.util.Scanner;
import javax.lang.model.util.ElementScanner14;
public class Main{
public static void main(String[] args) {
System.out.println("Display the details of an animal [1]");
System.out.println("Display the details of each animal [2]");
System.out.println("Display all animals of a particular type [3]");
System.out.println("Display the food required for all the animals [4]");
System.out.println("Display all the animals from a specified environment [5]");
MenuInput();
}
static void MenuInput()
{
System.out.println("Select an option by typing out the number that corresponds to the above options: ");
Scanner scan = new Scanner(System.in);
int input = scan.nextInt();
MenuChoice(input);
}
static void MenuChoice(int input)
{
Animal Saber = new Animal();
Saber.animal = "Tiger";
Saber.desc = "Tigers are the largest living cat species. They are mostly known for their black stripes and orange fur. They primarily eat deer, wild boar and elephant calves.";
Saber.type = "Mammal";
Saber.food = "Meat";
Saber.environment = "Jungle";
Saber.name = "Saber";
Saber.animaldesc = "Saber is a new addition to our zoo! Saber loves to make friends and is generally friendly around new people. Her mesmerizing yellow eyes, black striped orange fur and sharp fangs is a sight not to be missed!";
Animal Bingo = new Animal();
Bingo.animal = "Monkey";
Bingo.desc = "Monkeys are intelligent, social animals that tend to reside in the trees in jungles. Monkeys are mainly vegetarian however they can may eat meat as well. Some monkeys are small at about 15 centimetres whilst other monkeys are much larger at about 1 metre.";
Bingo.type = "Mammal";
Bingo.food = "Fruits, Nuts and Meat";
Bingo.environment = "Jungle";
Bingo.name = "Bingo";
Bingo.animaldesc = "Bingo is a funny and energetic monkey that loves to climb and socialize with visitors and especially his female counterpart Ella. Visitors are surely going to have a fun time with Bingo.";
Animal Ella = new Animal();
Ella.animal = "Monkey";
Ella.desc = "Monkeys are intelligent, social animals that tend to reside in the trees in jungles. Monkeys are mainly vegetarian however they can may eat meat as well. Some monkeys are small at about 15 centimetres whilst other monkeys are much larger at about 1 metre.";
Ella.type = "Mammal";
Ella.food = "Fruits, Nuts and Meat";
Ella.environment = "Jungle";
Ella.name = "Ella";
Ella.animaldesc = "Ella is Bingo's female counterpart. While not as energetic or sociable as Bingo, Ella still finds comfort in her zoo habitat and visitors and enjoys climbing with Bingo when she is in the mood.";
Animal Iris = new Animal();
Iris.animal = "Owl";
Iris.desc = "Owls are a species of bird known for being solitary and nocturnal. Fun fact: They are the only large group of birds that hunt at night. They eat mammals such as insects and other birds.";
Iris.type = "Bird";
Iris.food = "Insects and Meat";
Iris.environment = "Forest";
Iris.name = "Iris";
Iris.animaldesc = "Iris is a quiet bird who enjoys being by herself in the trees. Her fluffy feathers and golden eyes will make anyone dazzled.";
Animal Lizzie = new Animal();
Lizzie.animal = "Lizard";
Lizzie.desc = "Lizards are a type of reptile that make up about 6,000 different species. The size of the lizard varies from geckos that are a few inches/cm to a Komodo dragon that are 3 metres long. They primarily eat worms.";
Lizzie.type = "Reptile";
Lizzie.food = "Worms";
Lizzie.environment = "Desert";
Lizzie.name = "Lizzie";
Lizzie.animaldesc = "Lizzie is a unique and interesting animal. She spends her days patiently waiting for any worms to cross her path. ";
Animal Ollie = new Animal();
Ollie.animal = "Clownfish";
Ollie.desc = "Clownfish are a type of fish that live in the Indian and Pacific Oceans. They reside in anemones under the sea. Clownfish can group to 18 centimetres. Clownfish can look orange, yellow or red. They primarily eat Food Scraps, Larvae and Algae.";
Ollie.type = "Fish";
Ollie.food = "Food Scraps, Larvae and Algae";
Ollie.environment = "Ocean";
Ollie.name = "Ollie";
Ollie.animaldesc = "Ollie spends his days swimming in his aquarium looking for food and fun places to swim.";
ArrayList AnimalList = new ArrayList();
AnimalList.add(Saber);
AnimalList.add(Bingo);
AnimalList.add(Ella);
AnimalList.add(Iris);
AnimalList.add(Lizzie);
AnimalList.add(Ollie);
if (input == 1)
{
System.out.println("Type the name of the animal you want to see the details of: ");
Scanner scan = new Scanner(System.in);
String animalnameinput = scan.nextLine();
if (animalnameinput.equals("Saber"))
{
System.out.println("Animal: " + Saber.animal);
System.out.println("Animal Description: " + Saber.desc);
System.out.println("Animal Type: " + Saber.type);
System.out.println("Food required: " + Saber.food);
System.out.println("Environment: " + Saber.environment);
System.out.println("Name: " + Saber.name);
System.out.println("Description: " + Saber.animaldesc);
MenuChoice2();
}
else if (animalnameinput.equals("Bingo"))
{
System.out.println("Animal: " + Bingo.animal);
System.out.println("Animal Description: " + Bingo.desc);
System.out.println("Animal Type: " + Bingo.type);
System.out.println("Food required: " + Bingo.food);
System.out.println("Environment: " + Bingo.environment);
System.out.println("Name: " + Bingo.name);
System.out.println("Description: " + Bingo.animaldesc);
MenuChoice2();
}
else if (animalnameinput.equals("Ella"))
{
System.out.println("Animal: " + Ella.animal);
System.out.println("Animal Description: " + Ella.desc);
System.out.println("Animal Type: " + Ella.type);
System.out.println("Food required: " + Ella.food);
System.out.println("Environment: " + Ella.environment);
System.out.println("Name: " + Ella.name);
System.out.println("Description: " + Ella.animaldesc);
MenuChoice2();
}
else if (animalnameinput.equals("Iris"))
{
System.out.println("Animal: " + Iris.animal);
System.out.println("Animal Description: " + Iris.desc);
System.out.println("Animal Type: " + Iris.type);
System.out.println("Food required: " + Iris.food);
System.out.println("Environment: " + Iris.environment);
System.out.println("Name: " + Iris.name);
System.out.println("Description: " + Iris.animaldesc);
MenuChoice2();
}
else if (animalnameinput.equals("Lizzie"))
{
System.out.println("Animal: " + Lizzie.animal);
System.out.println("Animal Description: " + Lizzie.desc);
System.out.println("Animal Type: " + Lizzie.type);
System.out.println("Food required: " + Lizzie.food);
System.out.println("Environment: " + Lizzie.environment);
System.out.println("Name: " + Lizzie.name);
System.out.println("Description: " + Lizzie.animaldesc);
MenuChoice2();
}
else if (animalnameinput.equals("Ollie"))
{
System.out.println("Animal: " + Ollie.animal);
System.out.println("Animal Description: " + Ollie.desc);
System.out.println("Animal Type: " + Ollie.type);
System.out.println("Food required: " + Ollie.food);
System.out.println("Environment: " + Ollie.environment);
System.out.println("Name: " + Ollie.name);
System.out.println("Description: " + Ollie.animaldesc);
MenuChoice2();
}
else
{
System.out.println("Invalid input! Please enter the name of an animal that exists in the zoo: ");
MenuChoice2();
}
}
else if(input == 2)
{
System.out.println("Saber's details: \n" );
System.out.println("Animal: " + Saber.animal);
System.out.println("Animal Description: " + Saber.desc);
System.out.println("Animal Type: " + Saber.type);
System.out.println("Food required: " + Saber.food);
System.out.println("Environment: " + Saber.environment);
System.out.println("Name: " + Saber.name);
System.out.println("Description: " + Saber.animaldesc);
System.out.println("\nBingo's details: \n");
System.out.println("Animal: " + Bingo.animal);
System.out.println("Animal Description: " + Bingo.desc);
System.out.println("Animal Type: " + Bingo.type);
System.out.println("Food required: " + Bingo.food);
System.out.println("Environment: " + Bingo.environment);
System.out.println("Name: " + Bingo.name);
System.out.println("Description: " + Bingo.animaldesc);
System.out.println("\nElla's details: \n");
System.out.println("Animal: " + Ella.animal);
System.out.println("Animal Description: " + Ella.desc);
System.out.println("Animal Type: " + Ella.type);
System.out.println("Food required: " + Ella.food);
System.out.println("Environment: " + Ella.environment);
System.out.println("Name: " + Ella.name);
System.out.println("Description: " + Ella.animaldesc);
System.out.println("\nIris's details: \n");
System.out.println("Animal: " + Iris.animal);
System.out.println("Animal Description: " + Iris.desc);
System.out.println("Animal Type: " + Iris.type);
System.out.println("Food required: " + Iris.food);
System.out.println("Environment: " + Iris.environment);
System.out.println("Name: " + Iris.name);
System.out.println("Description: " + Iris.animaldesc);
System.out.println("\nLizzie's details: \n");
System.out.println("Animal: " + Lizzie.animal);
System.out.println("Animal Description: " + Lizzie.desc);
System.out.println("Animal Type: " + Lizzie.type);
System.out.println("Food required: " + Lizzie.food);
System.out.println("Environment: " + Lizzie.environment);
System.out.println("Name: " + Lizzie.name);
System.out.println("Description: " + Lizzie.animaldesc);
System.out.println("\nOllie's details: \n");
System.out.println("Animal: " + Ollie.animal);
System.out.println("Animal Description: " + Ollie.desc);
System.out.println("Animal Type: " + Ollie.type);
System.out.println("Food required: " + Ollie.food);
System.out.println("Environment: " + Ollie.environment);
System.out.println("Name: " + Ollie.name);
System.out.println("Description: " + Ollie.animaldesc);
MenuChoice2();
}
else if (input == 3)
{
System.out.println("Type in the type of animal you want to filter down to: ");
Scanner scan = new Scanner(System.in);
String animaltypeinput = scan.nextLine();
if (animaltypeinput.equals("Tiger"))
{
System.out.println("\n" + Saber.name);
MenuChoice2();
}
else if (animaltypeinput.equals("Monkey"))
{
System.out.println("\n" + Bingo.name);
System.out.println(Ella.name);
MenuChoice2();
}
else if (animaltypeinput.equals("Owl"))
{
System.out.println("\n" + Iris.name);
MenuChoice2();
}
else if (animaltypeinput.equals("Lizard"))
{
System.out.println("\n" + Lizzie.name);
MenuChoice2();
}
else if (animaltypeinput.equals("Clownfish"))
{
System.out.println("\n" + Ollie.name);
MenuChoice2();
}
else
{
System.out.println("Invalid input! Please input a valid type of animal that is in the zoo: ");
MenuChoice2();
}
}
else if (input == 4)
{
System.out.println("Saber's required food: " + Saber.food);
System.out.println("Bingo's required food: " + Bingo.food);
System.out.println("Ella's required food: " + Ella.food);
System.out.println("Iris's required food: " + Iris.food);
System.out.println("Lizzie's required food: " + Lizzie.food);
System.out.println("Ollie's required food: " + Ollie.food);
MenuChoice2();
}
else if (input == 5)
{
System.out.println("Type in the environment you want to filter the details to: ");
Scanner scan = new Scanner(System.in);
String animalenvironmentinput = scan.nextLine();
if (animalenvironmentinput.equals("Jungle"))
{
System.out.println("\n" + Saber.name);
System.out.println(Bingo.name);
System.out.println(Ella.name);
MenuChoice2();
}
else if (animalenvironmentinput.equals("Forest"))
{
System.out.println("\n" + Iris.name);
MenuChoice2();
}
else if (animalenvironmentinput.equals("Desert"))
{
System.out.println("\n" + Lizzie.name);
MenuChoice2();
}
else if (animalenvironmentinput.equals("Ocean"))
{
System.out.println("\n" + Ollie.name);
MenuChoice2();
}
else
{
System.out.println("Invalid input! Please input a valid environment that an animal in the zoo is adapted to live in.");
MenuChoice2();
}
}
else
{
System.out.println("Invalid input! Please enter a valid menu option: ");
MenuChoice2();
}
}
static void MenuChoice2()
{
System.out.println("Go back to menu selection [1]");
System.out.println("Exit the Application [2]");
Scanner scan = new Scanner(System.in);
int MenuChoice = scan.nextInt();
if (MenuChoice == 1)
{
MenuInput();
}
else if (MenuChoice == 2)
{
System.exit(0);
}
else
{
System.out.println("Invalid input! Please input a valid menu option: ");
MenuChoice2();
}
}
}
\ 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