Commit 9a7c7e11 authored by jinny.wilkin's avatar jinny.wilkin

Final

parent 5204d033
File added
......@@ -31,7 +31,7 @@ abstract public class Animal{
this.speed = spd;
}
public void getDetailsBase(){
public void getDetails(){
System.out.printf("Name: %s\nHabitat: %s\n Diet: %s\n Age: %d\n Integument: %s\n Gender: %s\n Number of Legs: %d\n Max Speed: %d\n",
this.name, this.habitat, this.food, this.age, this.integument, this.gender, this.numOfLegs, this.speed);
}
......
File added
......@@ -17,4 +17,12 @@ public class Baboon extends Mammal{
System.out.println("OOAAAAOOOAAAAHAAAWWOOOHAAA");
}
@Override
public void getDetails(){
System.out.printf("Name: %s\nHabitat: %s\n Diet: %s\n Age: %d\n Integument: %s\n Gender: %s\n Number of Legs: %d\n Max Speed: %d\n",
this.name, this.habitat, this.food, this.age, this.integument, this.gender, this.numOfLegs, this.speed);
System.out.printf("Height: %f\nLocomotion: %s\n", this.height, this.locomotion);
System.out.printf("Hierarchy: %d", this.hierarchy);
}
}
File added
......@@ -26,4 +26,11 @@ abstract class Bird extends Animal{
public void flight(){
System.out.println(this.name + " flew " + df.format(this.speed) + "m!");
}
@Override
public void getDetails(){
System.out.printf("Name: %s\nHabitat: %s\n Diet: %s\n Age: %d\n Integument: %s\n Gender: %s\n Number of Legs: %d\n Max Speed: %d\n",
this.name, this.habitat, this.food, this.age, this.integument, this.gender, this.numOfLegs, this.speed);
System.out.printf("Wing Span: %f\nPlumage Colour: %s\n", this.wingSpan, this.featherColour);
}
}
File added
......@@ -7,4 +7,12 @@ public class Catfish extends Fish{
whiskerLength = wl;
}
@Override
public void getDetails(){
System.out.printf("Name: %s\nHabitat: %s\n Diet: %s\n Age: %d\n Integument: %s\n Gender: %s\n Number of Legs: %d\n Max Speed: %d\n",
this.name, this.habitat, this.food, this.age, this.integument, this.gender, this.numOfLegs, this.speed);
System.out.printf("Length: %d\nColourings: %s\n", this.length, this.Colourings);
System.out.printf("Barbel Length: %f", this.whiskerLength);
}
}
File added
......@@ -12,4 +12,12 @@ public class Chameleon extends Reptile{
currentColour = currCol;
}
@Override
public void getDetails(){
System.out.printf("Name: %s\nHabitat: %s\n Diet: %s\n Age: %d\n Integument: %s\n Gender: %s\n Number of Legs: %d\n Max Speed: %d\n",
this.name, this.habitat, this.food, this.age, this.integument, this.gender, this.numOfLegs, this.speed);
System.out.printf("Length: %f\nAmphibious: %s\n", this.length, this.amphibious);
System.out.printf("Current Colour: %s", this.currentColour);
}
}
File added
......@@ -12,4 +12,12 @@ public class Crocodile extends Reptile{
numberOfTeeth = not;
}
@Override
public void getDetails(){
System.out.printf("Name: %s\nHabitat: %s\n Diet: %s\n Age: %d\n Integument: %s\n Gender: %s\n Number of Legs: %d\n Max Speed: %d\n",
this.name, this.habitat, this.food, this.age, this.integument, this.gender, this.numOfLegs, this.speed);
System.out.printf("Length: %f\nAmphibious: %s\n", this.length, this.amphibious);
System.out.printf("Number of Teeth: %s", this.numberOfTeeth);
}
}
File added
public class Duck extends Bird{
protected Boolean bread = true;
protected Boolean bread = true; //do ducks like bread?
public Duck(String hb, String fd, String nm, int a, String integ, String gnd, int nol, int spd, double ws, String fc, boolean brd){
super(hb, fd, nm, a, integ, gnd, nol, spd, ws, fc);
bread = brd;
if(!bread){
bread = true;
bread = true; //Ducks always like bread
}
}
......@@ -14,4 +14,12 @@ public class Duck extends Bird{
System.out.println(this.name + "swims around the pond happily");
}
@Override
public void getDetails(){
System.out.printf("Name: %s\nHabitat: %s\n Diet: %s\n Age: %d\n Integument: %s\n Gender: %s\n Number of Legs: %d\n Max Speed: %d\n",
this.name, this.habitat, this.food, this.age, this.integument, this.gender, this.numOfLegs, this.speed);
System.out.printf("Wing Span: %f\nPlumage Colour: %s\n", this.wingSpan, this.featherColour);
System.out.printf("Loves: Bread");
}
}
File added
......@@ -15,4 +15,12 @@ public class Emu extends Bird{
public void flight(){
System.out.println("Emu's can't fly!");
}
@Override
public void getDetails(){
System.out.printf("Name: %s\nHabitat: %s\n Diet: %s\n Age: %d\n Integument: %s\n Gender: %s\n Number of Legs: %d\n Max Speed: %d\n",
this.name, this.habitat, this.food, this.age, this.integument, this.gender, this.numOfLegs, this.speed);
System.out.printf("Wing Span: %f\nPlumage Colour: %s\n", this.wingSpan, this.featherColour);
System.out.printf("Running Speed: %d", this.runningSpeed);
}
}
File added
......@@ -7,4 +7,11 @@ abstract public class Fish extends Animal{
Colourings = culs;
length = len;
}
@Override
public void getDetails(){
System.out.printf("Name: %s\nHabitat: %s\n Diet: %s\n Age: %d\n Integument: %s\n Gender: %s\n Number of Legs: %d\n Max Speed: %d\n",
this.name, this.habitat, this.food, this.age, this.integument, this.gender, this.numOfLegs, this.speed);
System.out.printf("Length: %d\nColourings: %s\n", this.length, this.Colourings);
}
}
File added
......@@ -11,4 +11,12 @@ public class Lion extends Mammal{
super(hb, fd, nm, a, integ, gnd, nol, spd, hgt, loco);
timeSpentAsleep = tsa;
}
@Override
public void getDetails(){
System.out.printf("Name: %s\nHabitat: %s\n Diet: %s\n Age: %d\n Integument: %s\n Gender: %s\n Number of Legs: %d\n Max Speed: %d\n",
this.name, this.habitat, this.food, this.age, this.integument, this.gender, this.numOfLegs, this.speed);
System.out.printf("Height: %f\nLocomotion: %s\n", this.height, this.locomotion);
System.out.printf("Time Spent Sleeping: %d", this.timeSpentAsleep);
}
}
File added
......@@ -15,5 +15,10 @@ abstract public class Mammal extends Animal{
locomotion = loco;
}
@Override
public void getDetails(){
System.out.printf("Name: %s\nHabitat: %s\n Diet: %s\n Age: %d\n Integument: %s\n Gender: %s\n Number of Legs: %d\n Max Speed: %d\n",
this.name, this.habitat, this.food, this.age, this.integument, this.gender, this.numOfLegs, this.speed);
System.out.printf("Height: %f\nLocomotion: %s\n", this.height, this.locomotion);
}
}
File added
......@@ -16,4 +16,12 @@ public class Parrot extends Bird{
System.out.println("squark! " + input + " squark!");
}
@Override
public void getDetails(){
System.out.printf("Name: %s\nHabitat: %s\n Diet: %s\n Age: %d\n Integument: %s\n Gender: %s\n Number of Legs: %d\n Max Speed: %d\n",
this.name, this.habitat, this.food, this.age, this.integument, this.gender, this.numOfLegs, this.speed);
System.out.printf("Wing Span: %f\nPlumage Colour: %s\n", this.wingSpan, this.featherColour);
System.out.printf("Volume: %sdb", this.volumeDecibels);
}
}
......@@ -11,4 +11,12 @@ public class PufferFish extends Fish{
public void expansion(){
isExpanded = !isExpanded;
}
@Override
public void getDetails(){
System.out.printf("Name: %s\nHabitat: %s\n Diet: %s\n Age: %d\n Integument: %s\n Gender: %s\n Number of Legs: %d\n Max Speed: %d\n",
this.name, this.habitat, this.food, this.age, this.integument, this.gender, this.numOfLegs, this.speed);
System.out.printf("Length: %d\nColourings: %s\n", this.length, this.Colourings);
System.out.printf("Expanded Radius: %s", this.radiusExpanded);
}
}
File added
......@@ -18,4 +18,12 @@ public class RedPanda extends Mammal{
public void climbTree(){
System.out.println(this.name + " climbs " + df.format(this.speed) + " feet up a tree!");
}
@Override
public void getDetails(){
System.out.printf("Name: %s\nHabitat: %s\n Diet: %s\n Age: %d\n Integument: %s\n Gender: %s\n Number of Legs: %d\n Max Speed: %d\n",
this.name, this.habitat, this.food, this.age, this.integument, this.gender, this.numOfLegs, this.speed);
System.out.printf("Height: %f\nLocomotion: %s\n", this.height, this.locomotion);
System.out.printf("Social Distance: %f", this.homeRange);
}
}
File added
......@@ -15,4 +15,11 @@ abstract class Reptile extends Animal{
length = len;
}
@Override
public void getDetails(){
System.out.printf("Name: %s\nHabitat: %s\n Diet: %s\n Age: %d\n Integument: %s\n Gender: %s\n Number of Legs: %d\n Max Speed: %d\n",
this.name, this.habitat, this.food, this.age, this.integument, this.gender, this.numOfLegs, this.speed);
System.out.printf("Length: %f\nAmphibious: %s\n", this.length, this.amphibious);
}
}
File added
......@@ -7,4 +7,11 @@ public class Shark extends Fish{
teeth = tth;
}
@Override
public void getDetails(){
System.out.printf("Name: %s\nHabitat: %s\n Diet: %s\n Age: %d\n Integument: %s\n Gender: %s\n Number of Legs: %d\n Max Speed: %d\n",
this.name, this.habitat, this.food, this.age, this.integument, this.gender, this.numOfLegs, this.speed);
System.out.printf("Length: %d\nColourings: %s\n", this.length, this.Colourings);
System.out.printf("Number of Teeth: %d", this.teeth);
}
}
File added
......@@ -11,4 +11,12 @@ public class Turtle extends Reptile{
super(hb, fd, nm, a, integ, gnd, nol, spd, amph, len);
shellPattern = shpt;
}
@Override
public void getDetails(){
System.out.printf("Name: %s\nHabitat: %s\n Diet: %s\n Age: %d\n Integument: %s\n Gender: %s\n Number of Legs: %d\n Max Speed: %d\n",
this.name, this.habitat, this.food, this.age, this.integument, this.gender, this.numOfLegs, this.speed);
System.out.printf("Length: %f\nAmphibious: %s\n", this.length, this.amphibious);
System.out.printf("Shell Pattern: %s", this.shellPattern);
}
}
File added
import java.util.ArrayList;
import java.util.Arrays;
public class Zoo {
public Animal[] animals;
public void main(){
public static void main(String[] args){
Animal baboon1 = new Baboon("Savanna", "Fruits, Insects, Rodents", "Archie", 22, "Furry", "Male", 2, 30, 100d, "Bipedal", 0 );
Animal baboon2 = new Baboon("Savanna", "Fruits, Insects, Rodents", "Stal", 15, "Furry", "Female", 2, 30, 100d, "Bipedal", 5 );
Animal Lion1 = new Lion("Savanna", "Red Meat", "Kumali", 12, "Furry", "Male", 4, 46, 100d, "Quadrapedal", 22 );
Animal Lion2 = new Lion("Savanna", "Red Meat", "Martha", 8, "Furry", "Female", 4, 46, 100d, "Quadrapedal", 20 );
Animal RedPanda1 = new RedPanda("Forest", "Fruits, Bamboo", "Aster", 3, "Furry", "Female", 4, 23, 60.5d, "Quadrapedal", 0.94d);
Animal RedPanda2 = new RedPanda("Forest", "Fruits, Bamboo", "Felix", 5, "Furry", "Female", 4, 23, 60.5d, "Quadrapedal", 0.94d);
Animal Turtle1 = new Turtle("Tropical", "Fruits, Leaves", "Paul", 82, "Exoskeleton", "Male", 4, 1, true, 1.8d, "Star");
Animal Turtle2 = new Turtle("Tropical", "Fruits, Leaves", "Charlie", 70, "Exoskeleton", "Female", 4, 1, true, 1.8d, "Heart");
Animal Crocodile1 = new Crocodile("Saltwater", "Fish, Birds, Carrion", "Dody", 25, "Armoured Skin", "Female", 4, 11, true, 5d, 80);
Animal Crocodile2 = new Crocodile("Saltwater", "Fish, Birds, Carrion", "Jenny", 23, "Armoured Skin", "Female", 4, 11, true, 5d, 80);
Animal Chameleon1 = new Chameleon("Rainforest", "Insects", "George", 4, "Pigmented Skin", "Female", 5, 21, false, 0.2d, "Red");
Animal Chameleon2 = new Chameleon("Rainforest", "Insects", "Moss", 3, "Pigmented Skin", "Female", 5, 21, false, 0.23d, "Pink");
Animal Shark1 = new Shark("Ocean", "Fish", "Gilbert", 14, "Scales", "Male", 0, 32, "Grey", 4, 50);
Animal Shark2 = new Shark("Ocean", "Fish", "Spud", 5, "Scales", "Female", 0, 32, "Grey", 6, 50);
Animal Puffer1 = new PufferFish("Ocean", "Algae", "Tano", 6, "Collagen", "Female", 0, 15, "Yellow", 5, 15);
Animal Puffer2 = new PufferFish("Ocean", "Algae", "Brad", 6, "Collagen", "Male", 0, 15, "Yellow", 5, 15);
Animal Catfish1 = new Catfish("Rivers", "Algae", "Macy", 12, "Mucas", "Female", 0, 1, "Brown", 12, 2);
Animal Catfish2 = new Catfish("Rivers", "Algae", "Cristy", 11, "Mucas", "Female", 0, 1, "Brown", 12, 2);
Animal Parrot1 = new Parrot("Tropical", "Seeds, Fruit", "Alex", 45, "Feathers", "Male", 2, 120, .5d, "grey", 90);
Animal Parrot2 = new Parrot("Tropical", "Seeds, Fruit", "Stephen", 30, "Feathers", "Male", 2, 130, .6d, "grey", 95);
Animal Emu1 = new Emu("Savanna", "Seeds, Insects", "Boyd", 15, "Feather", "Female", 2, 30, .2d, "grey");
Animal Emu2 = new Emu("Savanna", "Seeds, Insects", "Clid", 11, "Feather", "Female", 2, 30, .2d, "grey");
Animal Duck1 = new Duck("River", "Grass, Seeds", "Clive", 2, "Feathers", "Male", 2, 50, .9d, "Grey", true);
Animal Duck2 = new Duck("River", "Grass, Seeds", "Heather", 4, "Feathers", "Female", 2, 50, .8d, "brown", false);
ArrayList<Animal> AnimalList = new ArrayList<>(Arrays.asList(baboon1, baboon2, Lion1, Lion2, RedPanda1, RedPanda2, Turtle1, Turtle2, Crocodile1, Crocodile2, Chameleon1, Chameleon2, Shark1, Shark2, Puffer1, Puffer2, Catfish1, Catfish2, Parrot1, Parrot2, Emu1, Emu2, Duck1, Duck2));
for (Animal animal : AnimalList) {
System.out.println(animal.name + " the " + animal.getClass().getSimpleName());
}
//Parrot1.getDetails();
/*for (Animal animal : AnimalList) {
if(animal instanceof Fish){
animal.getDetails();
}
} */
ArrayList<Animal> Mammals = new ArrayList<>();
ArrayList<Animal> Fishes = new ArrayList<>();
ArrayList<Animal> Birds = new ArrayList<>();
ArrayList<Animal> Reptiles = new ArrayList<>();
for (Animal animal : AnimalList) {
if(animal instanceof Mammal){
Mammals.add(animal);
}
if(animal instanceof Fish){
Fishes.add(animal);
}
if(animal instanceof Bird){
Birds.add(animal);
}
if(animal instanceof Reptile){
Reptiles.add(animal);
}
}
for (Animal animal : Birds){
System.out.println(animal.food);
}
ArrayList<String> habitatList = new ArrayList<>();
for(Animal animal: AnimalList){
if(!habitatList.contains(animal.habitat)){
habitatList.add(animal.habitat);
}
}
/*for(String habitat: habitatList){
System.out.print(habitat + ", ");
}*/
for(Animal animal: AnimalList){
if(animal.habitat == "Savanna"){
System.out.println(animal.name + " the " + animal.getClass().getSimpleName() + " lives in the Savanna");
}
}
}
}
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