From 5adb122027d22b708e2735af6b952bf4a7768b8a Mon Sep 17 00:00:00 2001 From: Jaeydon Date: Sun, 28 Jan 2024 23:27:47 -0600 Subject: [PATCH] Added Cow Class with makeNoise() --- Zoo/bin/.gitignore | 2 + Zoo/bin/main/Runner.class | Bin 612 -> 1310 bytes Zoo/src/main/Runner.java | 11 ++++-- Zoo/src/model/Cow.java | 76 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 4 deletions(-) create mode 100644 Zoo/bin/.gitignore create mode 100644 Zoo/src/model/Cow.java diff --git a/Zoo/bin/.gitignore b/Zoo/bin/.gitignore new file mode 100644 index 0000000..7f870ef --- /dev/null +++ b/Zoo/bin/.gitignore @@ -0,0 +1,2 @@ +/main/ +/model/ diff --git a/Zoo/bin/main/Runner.class b/Zoo/bin/main/Runner.class index 87c83e62b518850c14c2c798e4b5e24d3737cfa9..123b6831b3acdf3d083ba7a4bdf13afb41233af4 100644 GIT binary patch literal 1310 zcmaJ>YflqF6g|_@?zSwpl$ZE`qJS+Z>-#|gwN<1^L1Re`(Jw<8%ffc2+1*0=Py8GD z0TM|30sbiC9k#K>Hil$&?q%*d=bpLKU%$_O0$4>+Lx^Fp&Mn9M*mNA>Y8YTh9`GY> z+T5v`?{^PG)n|yVSdQhdF@!VO3d2A_?uj_Uh#80=%8)2oj@W9}cZIvncWuFtD#)3e4b0;X>61+|bu1{hr1^nb^{HXO>p3MNYhVG3N_di+wKJ7f8J3g5--=~*8U~xRaBMlG9)r)Jm zEX=@TJRu7kN~=xRHP#Q6h9gpMk>4~|rN8FW9mmVE=~l(MrG{fLn6@QFLoVf|^gZ9@ zjZNY2%RMiS6|8AkWti>EgXJ8_LtzGE5wy9^tG;wws{fY^-@5g*PX~Y-+}X2*H(QeO zu-VA<+Srx3RJh%0h(5==XD)alxo$h#5Cv}AWy=@2L=-t4d1{+{NqfBIEvFfSQB*Ik zU~|tCo`$y!b3NVm)34zj!_@ze(sT#SVul`0n5G1@(%m3Rt45JYUq;`^!YTCcv2!#`L+4;Sr%09-PcYm8xpKj%L#HBxU=`SSP=Ha4 zQKS>aIKk3mR&Tlu`-OH2HhqqXoz!INdNP{2d5Y=M58NV#%o*+iC%FGFQvyj0W15gU pOle|PvXk`p6winujOP@G@B+&h3K(8d_B9F=sh^iOSjPq?{{Sw)I3@r9 delta 198 zcmbQo^@N4%)W2Q(7#J9A8I&e+J(T6m%}+_q(RZy#%q_@CGl)lSXOQ&K-o_vmz7Z(G#J~j-XJ7`BybK&b7B7PU12>Q-2GPO50~BEZ%CIrW QF~~D80-*ws&%~ez0Lh~#cK`qY diff --git a/Zoo/src/main/Runner.java b/Zoo/src/main/Runner.java index ed1b309..ac67049 100644 --- a/Zoo/src/main/Runner.java +++ b/Zoo/src/main/Runner.java @@ -1,6 +1,6 @@ package main; -import model.Example; +import model.Cow; public class Runner { @@ -9,9 +9,12 @@ public static void main(String[] args) { run.go(); } - private void go() { - Example example = new Example(); - example.makeNoise(); +private void go() { + //create instance of animal and print results + Cow myCow = new Cow("Beefalo", "Maggie", 6, "Brown"); + + System.out.println("Cow says: " + myCow.makeNoise()); + } } diff --git a/Zoo/src/model/Cow.java b/Zoo/src/model/Cow.java new file mode 100644 index 0000000..53d74b6 --- /dev/null +++ b/Zoo/src/model/Cow.java @@ -0,0 +1,76 @@ +package model; + +public class Cow{ + private String breed; + private String name; + private int age; + private String color; + + // Default constructor + public Cow() { + super(); + } + + /** + * Parameterized constructor for cow class + * @param breed The breed of the cow + * @param name The name of the cow + * @param age The age of the cow + * @param color The color of the cow + */ + public Cow(String breed, String name, int age, String color) { + super(); + this.breed = breed; + this.name = name; + this.age = age; + this.color = color; + } + + + public String getBreed() { + return breed; + } + + + public void setBreed(String breed) { + this.breed = breed; + } + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + public int getAge() { + return age; + } + + + public void setAge(int age) { + this.age = age; + } + + + public String getColor() { + return color; + } + + void setColor(String color) { + this.color = color; + } + + @Override + public String toString() { + return "Cow [name=" + name + ", breed=" + breed + ", age=" + age + ", color=" + color + "]"; + } + + + public String makeNoise() { + return "Mooooo!"; + } +} \ No newline at end of file