From e38ef41e9cc245acf6feedda8a69134cc5418188 Mon Sep 17 00:00:00 2001 From: Andrew Linsey Date: Tue, 15 Sep 2026 20:19:38 -0400 Subject: [PATCH 1/6] First commit --- AnimalZoo/src/Animal.java | 18 ++++++++++++++++++ AnimalZoo/src/Habitat.java | 11 +++++++++++ AnimalZoo/src/Trainable.java | 3 +++ 3 files changed, 32 insertions(+) create mode 100644 AnimalZoo/src/Animal.java create mode 100644 AnimalZoo/src/Habitat.java create mode 100644 AnimalZoo/src/Trainable.java diff --git a/AnimalZoo/src/Animal.java b/AnimalZoo/src/Animal.java new file mode 100644 index 0000000..380ccfc --- /dev/null +++ b/AnimalZoo/src/Animal.java @@ -0,0 +1,18 @@ +public abstract class Animal { + + private String m_name; + private int m_age; + private Habitat m_habitat; + + public Animal(String name, int age, Habitat habitat) { + m_name = name; + m_age = age; + m_habitat = habitat; + } + + public String getName() { + return m_name; + } + + +} diff --git a/AnimalZoo/src/Habitat.java b/AnimalZoo/src/Habitat.java new file mode 100644 index 0000000..a60ed8b --- /dev/null +++ b/AnimalZoo/src/Habitat.java @@ -0,0 +1,11 @@ +public enum Habitat { + SAVANNAH(85), + ARTIC(-20), + Forest(60); + + private int m_temp; + + private Habitat(int tempature) { + m_temp = tempature; + } +} diff --git a/AnimalZoo/src/Trainable.java b/AnimalZoo/src/Trainable.java new file mode 100644 index 0000000..cf82ca4 --- /dev/null +++ b/AnimalZoo/src/Trainable.java @@ -0,0 +1,3 @@ +public interface Trainable { + public abstract void performTrick(); +} From 07d7bb4c36dea74daeb5591403c21687a8c6dbcb Mon Sep 17 00:00:00 2001 From: Andrew Linsey Date: Tue, 15 Sep 2026 20:23:46 -0400 Subject: [PATCH 2/6] Fixed Spelling error --- AnimalZoo/src/App.java | 2 +- AnimalZoo/src/Habitat.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AnimalZoo/src/App.java b/AnimalZoo/src/App.java index 0a839f9..2add349 100644 --- a/AnimalZoo/src/App.java +++ b/AnimalZoo/src/App.java @@ -1,5 +1,5 @@ public class App { public static void main(String[] args) throws Exception { - System.out.println("Hello, World!"); + } } diff --git a/AnimalZoo/src/Habitat.java b/AnimalZoo/src/Habitat.java index a60ed8b..5d0eac4 100644 --- a/AnimalZoo/src/Habitat.java +++ b/AnimalZoo/src/Habitat.java @@ -1,7 +1,7 @@ public enum Habitat { SAVANNAH(85), ARTIC(-20), - Forest(60); + FOREST(60); private int m_temp; From dfb593c622f71a9ce1ac3f65f139b942a4c888ca Mon Sep 17 00:00:00 2001 From: Andrew Linsey Date: Tue, 15 Sep 2026 21:29:07 -0400 Subject: [PATCH 3/6] Final commit --- AnimalZoo/src/BlackBear.java | 36 +++++++++++++++++++++++++++++ AnimalZoo/src/Lion.java | 44 ++++++++++++++++++++++++++++++++++++ AnimalZoo/src/Penguin.java | 33 +++++++++++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 AnimalZoo/src/BlackBear.java create mode 100644 AnimalZoo/src/Lion.java create mode 100644 AnimalZoo/src/Penguin.java diff --git a/AnimalZoo/src/BlackBear.java b/AnimalZoo/src/BlackBear.java new file mode 100644 index 0000000..84fc7f1 --- /dev/null +++ b/AnimalZoo/src/BlackBear.java @@ -0,0 +1,36 @@ +import java.util.Random; + +public class BlackBear extends Animal{ + public BlackBear(String name, int age) { + super(name, age, Habitat.FOREST); + } + + @Override + public String toString() { + return (m_name + " the Black Bear lives in the " + m_habitat + " and " + m_name + " is " + m_age + " years old"); + } + + @Override + public void makeSound() { + Random soundRand = new Random(); + int m_check = soundRand.nextInt(1, 3); + if(m_check == 1) { + System.out.println(m_name + " the Black bear growels loudly"); + } + else if(m_check == 2) { + System.out.println(m_name + " the Black Bear makes a terrifying roar"); + } + } + + public void forage() { + System.out.println(m_name + " the Black Bear gets berries from a near by bush and eats it right there."); + } + + public void climbTree() { + System.out.println(m_name + " the Black Bear climbs a nearby tree"); + } + + public void hibernate() { + System.out.println(m_name + " the Black Bear goes to sleep"); + } +} diff --git a/AnimalZoo/src/Lion.java b/AnimalZoo/src/Lion.java new file mode 100644 index 0000000..e4774b1 --- /dev/null +++ b/AnimalZoo/src/Lion.java @@ -0,0 +1,44 @@ +import java.util.Random; + +public class Lion extends Animal implements Trainable { + + public Lion(String name, int age) { + super(name, age, Habitat.SAVANNAH); + } + + @Override + public String toString() { + return (m_name + " the lion lives in the " + m_habitat + " and " + m_name + " is " + m_age + " years old"); + } + + @Override + public void makeSound() { + Random soundRand = new Random(); + int m_check = soundRand.nextInt(1, 3); + if(m_check == 1) { + System.out.println(m_name + " the Lion roars loudly"); + } + else if(m_check == 2) { + System.out.println(m_name + " the Lion meows softly"); + } + } + + @Override + public void performTrick() { + Random soundRand = new Random(); + int m_check = soundRand.nextInt(1, 4); + if(m_check == 1) { + System.out.println(m_name + " the Lion jumps through a hoop of fire"); + } + else if(m_check == 2) { + System.out.println(m_name + " the Lion eats a chunk of meat in under 3 seconds a new rocord for " + m_name); + } + else if(m_check == 3) { + System.out.println(m_name + " the lion eats a chunk lf meat in under 5 seconds " + m_name + " looks sad"); + } + } + + public void hunt() { + System.out.println(m_name + " the lion kills one of the penguins and eats it right there."); + } +} diff --git a/AnimalZoo/src/Penguin.java b/AnimalZoo/src/Penguin.java new file mode 100644 index 0000000..1258f9d --- /dev/null +++ b/AnimalZoo/src/Penguin.java @@ -0,0 +1,33 @@ +import java.util.Random; + +public class Penguin extends Animal{ + + public Penguin(String name, int age) { + super(name, age, Habitat.ARTIC); + } + + @Override + public String toString() { + return (m_name + " the Penguin lives in the " + m_habitat + " and " + m_name + " is " + m_age + " years old"); + } + + @Override + public void makeSound() { + Random soundRand = new Random(); + int m_check = soundRand.nextInt(1, 3); + if(m_check == 1) { + System.out.println(m_name + " the Penguin honks"); + } + else if(m_check == 2) { + System.out.println(m_name + " the Penguin stares into your soul and says nothing, the farts"); + } + } + + public void swim() { + System.out.println(m_name + " swims in a figure 8"); + } + + public void slide() { + System.out.println(m_name + " slides gracefully on its belly"); + } +} From cdc35f793e13100f03d4199a39fdb83b76ac50d0 Mon Sep 17 00:00:00 2001 From: Andrew Linsey Date: Wed, 16 Sep 2026 17:36:16 -0400 Subject: [PATCH 4/6] Fixed compile errors with App --- AnimalZoo/src/Animal.java | 10 ++++++---- AnimalZoo/src/App.java | 20 +++++++++++++++++++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/AnimalZoo/src/Animal.java b/AnimalZoo/src/Animal.java index 380ccfc..9df0928 100644 --- a/AnimalZoo/src/Animal.java +++ b/AnimalZoo/src/Animal.java @@ -1,8 +1,8 @@ public abstract class Animal { - private String m_name; - private int m_age; - private Habitat m_habitat; + protected String m_name; + protected int m_age; + protected Habitat m_habitat; public Animal(String name, int age, Habitat habitat) { m_name = name; @@ -14,5 +14,7 @@ public String getName() { return m_name; } - + public abstract String toString(); + + public abstract void makeSound(); } diff --git a/AnimalZoo/src/App.java b/AnimalZoo/src/App.java index 2add349..125e611 100644 --- a/AnimalZoo/src/App.java +++ b/AnimalZoo/src/App.java @@ -1,5 +1,23 @@ public class App { public static void main(String[] args) throws Exception { - + Lion lion = new Lion("Billy", 3); + Penguin penguin = new Penguin("Bob", 2); + BlackBear blackBear = new BlackBear("Boby", 4); + + lion.toString(); + lion.makeSound(); + lion.hunt(); + lion.performTrick(); + + penguin.toString(); + penguin.makeSound(); + penguin.slide(); + penguin.swim(); + + blackBear.toString(); + blackBear.makeSound(); + blackBear.forage(); + blackBear.climbTree(); + blackBear.hibernate(); } } From 3bfd58b8e6a750d6adcb4a0a273a5b79b8dd5d96 Mon Sep 17 00:00:00 2001 From: Andrew Linsey Date: Wed, 16 Sep 2026 19:17:52 -0400 Subject: [PATCH 5/6] Fixed erros with printing To String --- AnimalZoo/src/App.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AnimalZoo/src/App.java b/AnimalZoo/src/App.java index 125e611..09689e3 100644 --- a/AnimalZoo/src/App.java +++ b/AnimalZoo/src/App.java @@ -4,17 +4,17 @@ public static void main(String[] args) throws Exception { Penguin penguin = new Penguin("Bob", 2); BlackBear blackBear = new BlackBear("Boby", 4); - lion.toString(); + System.out.println(lion.toString()); lion.makeSound(); lion.hunt(); lion.performTrick(); - penguin.toString(); + System.out.println(penguin.toString()); penguin.makeSound(); penguin.slide(); penguin.swim(); - blackBear.toString(); + System.out.println(blackBear.toString()); blackBear.makeSound(); blackBear.forage(); blackBear.climbTree(); From b53c93be96d1c1cb2a9df42dc246b52b5181d24b Mon Sep 17 00:00:00 2001 From: Andrew Linsey Date: Wed, 16 Sep 2026 20:32:50 -0400 Subject: [PATCH 6/6] Fixed errors with not enough information --- AnimalZoo/src/BlackBear.java | 2 +- AnimalZoo/src/Habitat.java | 4 ++++ AnimalZoo/src/Lion.java | 2 +- AnimalZoo/src/Penguin.java | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/AnimalZoo/src/BlackBear.java b/AnimalZoo/src/BlackBear.java index 84fc7f1..bd4f3c1 100644 --- a/AnimalZoo/src/BlackBear.java +++ b/AnimalZoo/src/BlackBear.java @@ -7,7 +7,7 @@ public BlackBear(String name, int age) { @Override public String toString() { - return (m_name + " the Black Bear lives in the " + m_habitat + " and " + m_name + " is " + m_age + " years old"); + return (m_name + " the Black Bear lives in the " + m_habitat + " where it is " + m_habitat.getTemp() + " degrees fahrenheit and " + m_name + " is " + m_age + " years old"); } @Override diff --git a/AnimalZoo/src/Habitat.java b/AnimalZoo/src/Habitat.java index 5d0eac4..b7ecc8a 100644 --- a/AnimalZoo/src/Habitat.java +++ b/AnimalZoo/src/Habitat.java @@ -8,4 +8,8 @@ public enum Habitat { private Habitat(int tempature) { m_temp = tempature; } + + public int getTemp() { + return m_temp; + } } diff --git a/AnimalZoo/src/Lion.java b/AnimalZoo/src/Lion.java index e4774b1..a5c6239 100644 --- a/AnimalZoo/src/Lion.java +++ b/AnimalZoo/src/Lion.java @@ -8,7 +8,7 @@ public Lion(String name, int age) { @Override public String toString() { - return (m_name + " the lion lives in the " + m_habitat + " and " + m_name + " is " + m_age + " years old"); + return (m_name + " the lion lives in the " + m_habitat + " where it is " + m_habitat.getTemp() + " degrees fahrenheit and " + m_name + " is " + m_age + " years old"); } @Override diff --git a/AnimalZoo/src/Penguin.java b/AnimalZoo/src/Penguin.java index 1258f9d..9cec6d6 100644 --- a/AnimalZoo/src/Penguin.java +++ b/AnimalZoo/src/Penguin.java @@ -8,7 +8,7 @@ public Penguin(String name, int age) { @Override public String toString() { - return (m_name + " the Penguin lives in the " + m_habitat + " and " + m_name + " is " + m_age + " years old"); + return (m_name + " the Penguin lives in the " + m_habitat + " where it is " + m_habitat.getTemp() + " degrees fahrenheit and " + m_name + " is " + m_age + " years old"); } @Override