Commit a17f42e8 authored by Connor's avatar Connor

Assignment

parents
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>YSJZoo</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
//We first begin by making the Animals class
public class Animals {
//This class is going to host our string vairables as shown below
String name;
String habitat;
String type;
String diet;
String description;
public void fact() {System.out.println("A " + this.name + "'s habitat is " + this.habitat + ". They are a specises of " + this.type); }
}
\ No newline at end of file
public class Bear extends Mammals {
public Bear(String name) {
this.name = name;
this.habitat = "Forest";
this.type = "Mammal";
this.description = "Roughly, 98% of the US Grizzly Bear population lives in Alaska";
this.diet = "Fish";
}
}
\ No newline at end of file
public abstract class Birds extends Animals {
//Swim is a attribute that all Fish will have in common
public void Fly() {
System.out.println("Fly");
}
}
public class Clownfish extends Fish {
public Clownfish(String name) {
this.name = name;
this.habitat = "Ocean";
this.type = "Fish";
this.description = "Clownfish make their homes amongst reefs";
this.diet = "Seaweed";
}
}
\ No newline at end of file
public abstract class Fish extends Animals {
//Swim is a attribute that all Fish will have in common
public void Swim() {
System.out.println("Swims");
}
}
public class Fox extends Mammals {
public Fox(String name) {
this.name = name;
this.habitat = "Forest";
this.type = "Mammal";
this.description = "Foxes can make around 40 distinctly different sounds";
this.diet = "Rabbits";
}
}
\ No newline at end of file
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in); //Allows the user to input selections and generally interact with the code
int choice;
ArrayList<Animals> aSpecies = new ArrayList<Animals>();
aSpecies.add(new Monkey("Baboon"));
aSpecies.add(new Bear ("Grizzly Bear"));
aSpecies.add(new Fox("Gray Fox"));
aSpecies.add(new Clownfish ("Percula Clown"));
aSpecies.add(new Swordfish ("Broadbill Swordfish"));
aSpecies.add(new Shark("Great White Shark"));
aSpecies.add(new Parrot("Golden Parakeet"));
aSpecies.add(new Penguin("Emperor Penguin"));
aSpecies.add(new Toucan("Toco Toucan"));
/*The menu loop makes sure that when the user completes a choice path they can be brought back to the main menu
* without restarting the application, this allows for a smoother user experiance
*/
boolean menuLoop = true;
while (menuLoop == true ) {
//----------------------------Looped Content Begins-------------------
//Print out the welcome message and the menu choices for the user.
System.out.println("---------------Welcome to YSJ Zoo Information Terminal!--------------- \n");
System.out.println("Please choose from the following options of how I can serve you... \n");
System.out.println("1) View all of our Animals that we have at YSJ Zoo currently"
+ " \n 2) Looking for a certain animal? "
+ " \n 3) Learn some facts about the animals we look after?"
+ " \n 4) Perhaps your curious on what our animals eat for dinner?"
+ " \n 5) Power Off...Goodbye!");
//Getting the choice from the user with the scanner for later use
choice = input.nextInt();
if (choice == 1) {
for(int i=0; i<aSpecies.size();i++) {
System.out.println(aSpecies.get(i).name + "\n");
}
}
}
}
}
public abstract class Mammals extends Animals {
//MReproduce is a attribute that all Mammals will have in common
public void MReproduce() {
System.out.println("Gives birth to live young");
}
}
public class Monkey extends Mammals {
public Monkey(String name) {
this.name = name;
this.habitat = "Jungle";
this.type = "Mammal";
this.description = "Monkeys are found all over the planet with the exception of Australia and Antarctica";
this.diet = "Fruit";
}
}
\ No newline at end of file
public class Parrot extends Birds {
public Parrot(String name) {
this.name = name;
this.habitat = "Jungle";
this.type = "Bird";
this.description = "Parrots are able to imitate sounds that help them fit with their surroundings";
this.diet = "Fruits";
}
}
\ No newline at end of file
public class Penguin extends Birds {
public Penguin(String name) {
this.name = name;
this.habitat = "Arctic";
this.type = "Bird";
this.description = "The smallest species of penguin is only 30cm tall, they are called Little Blue penguins.";
this.diet = "Fish";
}
}
\ No newline at end of file
public class Shark extends Fish {
public Shark(String name) {
this.name = name;
this.habitat = "Ocean";
this.type = "Fish";
this.description = "Sharks are apex predators and have no natural predators";
this.diet = "Fish";
}
}
\ No newline at end of file
public class Swordfish extends Fish {
public Swordfish(String name) {
this.name = name;
this.habitat = "Ocean";
this.type = "Fish";
this.description = "Swordfish do not swim in schools but often travel and hunt alone.";
this.diet = "Octopus";
}
}
\ No newline at end of file
public class Toucan extends Birds {
public Toucan(String name) {
this.name = name;
this.habitat = "Jungle";
this.type = "Bird";
this.description = "A toucan, on average, can live to 20 years old";
this.diet = "Fruits";
}
}
\ 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