From a57a85e0dbd67cca7f8344fd30300bdd5b35306c Mon Sep 17 00:00:00 2001 From: tparrish2 Date: Tue, 17 Jan 2023 19:06:10 -0600 Subject: [PATCH] added GuineaPig and modified AnimalNoises --- src/AnimalNoises.java | 24 ++++++++------ src/model/GuineaPig.java | 67 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 10 deletions(-) create mode 100644 src/model/GuineaPig.java diff --git a/src/AnimalNoises.java b/src/AnimalNoises.java index 8b643ab..90a27c2 100644 --- a/src/AnimalNoises.java +++ b/src/AnimalNoises.java @@ -1,28 +1,32 @@ -//added semicolon to the end of import (Andrew Steele 01/10/2023) -import model.Example; -import model.Platypus; +/** + * @author Trevor Parrish - tparrish2 + * CIS175 - Spring 2023 + * Jan 17, 2023 + */ +import model.Platypus; import model.Dog; -import model.Example -import model.Example; import model.Cat; +import model.GuineaPig; + public class AnimalNoises { // add your animal class to the model package // only push this file and the animal class you created public static void main(String[] args) { - Example example = new Example(); - System.out.println(example.makeNoise()); - //created a new instance of the object and output the sound it makes + Platypus frank = new Platypus(); System.out.println(frank.makeNoise()); Dog Titan = new Dog(); System.out.println(Titan.makeNoise()); - 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()); + + // create GuineaPig object and print results of makeNoise method + GuineaPig daisy = new GuineaPig(); + System.out.println(daisy.makeNoise()); } - } + diff --git a/src/model/GuineaPig.java b/src/model/GuineaPig.java new file mode 100644 index 0000000..86c811b --- /dev/null +++ b/src/model/GuineaPig.java @@ -0,0 +1,67 @@ +package model; + +/** + * @author Trevor Parrish - tparrish2 + * CIS175 - Spring 2023 + * Jan 17, 2023 + */ +public class GuineaPig { + private String name; + private String color; + private int age; + /** + * @param habitat + * @param name + * @param length + */ + + public GuineaPig() { + + } + + public GuineaPig(String name, String color, int age) { + super(); + this.name = name; + this.color = color; + this.age = age; + } + + // get the name + public String getName() { + return name; + } + + // set the name + public void setName(String name) { + this.name = name; + } + + // get the color + public String getColor() { + return color; + } + + // set the color + public void setColor(String color) { + this.color = color; + } + + // get the age + public int getAge() { + return age; + } + + // set the age + public void setAge(int age) { + this.age = age; + } + + public String makeNoise() { + return "Squeak squeak!!"; + } + + @Override + public String toString() { + return "GuineaPig [name=" + name + ", color=" + color + ", age=" + age + "]"; + } +}