From 998acc951977dcc402ba754f931e39815ee43d87 Mon Sep 17 00:00:00 2001 From: Jacoby Date: Tue, 17 Jan 2023 20:48:23 -0600 Subject: [PATCH] added a new animal class and instance --- .classpath | 6 ++++ .gitignore | 1 + .project | 17 ++++++++++ src/AnimalNoises.java | 5 ++- src/model/Cow.java | 72 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 .classpath create mode 100644 .gitignore create mode 100644 .project create mode 100644 src/model/Cow.java diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..0cbf9cd --- /dev/null +++ b/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/.project b/.project new file mode 100644 index 0000000..bd0d2e3 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + ZooDMACCJava2Spring2023 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/src/AnimalNoises.java b/src/AnimalNoises.java index 8b643ab..cdc4ba0 100644 --- a/src/AnimalNoises.java +++ b/src/AnimalNoises.java @@ -3,9 +3,9 @@ import model.Platypus; import model.Dog; -import model.Example import model.Example; import model.Cat; +import model.Cow; public class AnimalNoises { // add your animal class to the model package @@ -23,6 +23,9 @@ public static void main(String[] args) { Cat jordan = new Cat("Jordan",6,true); System.out.println(jordan.getName() + " Age: " + jordan.getAge() + " Is Loved: " + jordan.getIsLoved()); System.out.println(jordan.getName() + ": " + jordan.speak()); + //created a new instance of a Cow and output the sound it makes (Jacoby King 01/17/23) + Cow susan = new Cow("Farm", "Susan", 10); + System.out.println(susan.getName() + ": " + susan.makeNoise()); } } diff --git a/src/model/Cow.java b/src/model/Cow.java new file mode 100644 index 0000000..5c29795 --- /dev/null +++ b/src/model/Cow.java @@ -0,0 +1,72 @@ +package model; + +/** + * @author jacoby - jking11@dmacc.edu + * CIS175 - Spring 2023 + * Jan 17, 2023 + */ +public class Cow { + private String habitat; + private String name; + private int age; + /** + * + */ + public Cow() { + super(); + } + /** + * @param habitat + * @param name + * @param age + */ + public Cow(String habitat, String name, int age) { + super(); + this.habitat = habitat; + this.name = name; + this.age = age; + } + /** + * @return the habitat + */ + public String getHabitat() { + return habitat; + } + /** + * @param habitat the habitat to set + */ + public void setHabitat(String habitat) { + this.habitat = habitat; + } + /** + * @return the name + */ + public String getName() { + return name; + } + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + /** + * @return the age + */ + public int getAge() { + return age; + } + /** + * @param age the age to set + */ + public void setAge(int age) { + this.age = age; + } + @Override + public String toString() { + return "Cow [habitat=" + habitat + ", name=" + name + ", age=" + age + "]"; + } + public String makeNoise() { + return "Moo!"; + } +}