From bd04c0b059832919699507709dd7c1bd66ada443 Mon Sep 17 00:00:00 2001
From: Ricardo M <95rikym@gmail.com>
Date: Sun, 14 Apr 2024 21:07:42 -0700
Subject: [PATCH] Done with Assignment 10
---
.idea/Java-Assignment-010.iml | 2 +-
.idea/misc.xml | 2 +-
README.md | 2 ++
src/Dog.java | 60 +++++++++++++++++++++++++++++++++++
src/DogPark.java | 56 ++++++++++++++++++++++++++++++++
src/DogSize.java | 6 ++++
src/Student.java | 19 +++++++++++
7 files changed, 145 insertions(+), 2 deletions(-)
create mode 100644 src/Dog.java
create mode 100644 src/DogPark.java
create mode 100644 src/DogSize.java
create mode 100644 src/Student.java
diff --git a/.idea/Java-Assignment-010.iml b/.idea/Java-Assignment-010.iml
index c90834f..8656db9 100644
--- a/.idea/Java-Assignment-010.iml
+++ b/.idea/Java-Assignment-010.iml
@@ -5,7 +5,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 639900d..fe784cd 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 833cd8b..fe4f1fd 100644
--- a/README.md
+++ b/README.md
@@ -36,6 +36,8 @@ class Student{
* Read the W3Schools page on class methods: [W3Schools Java Class Methods](https://www.w3schools.com/java/java_class_methods.asp)
* In your own words, write a few sentences below explaining the difference between static and public methods in relation to a class.
+* * public and static methods are similar but your invocation for them differ. With a static method you can call it anytime within that class to use it. As opposed to public methods where you must first create and object and then invoke it with dot notation( . )
+* * depending on your use a static or public method will be more efficient than the other.
## Part 3 - Dogs
diff --git a/src/Dog.java b/src/Dog.java
new file mode 100644
index 0000000..bd7e2b9
--- /dev/null
+++ b/src/Dog.java
@@ -0,0 +1,60 @@
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+public class Dog {
+
+ private String breed;
+ private DogSize size;
+ private List color;
+ private int age;
+ private String name;
+
+ public Dog(String breed, DogSize size, String[] color, int age, String name) {
+ this.breed = breed;
+ this.size = size;
+ this.color = new ArrayList<>();
+ for (int i=0; i dogsInPark;
+
+ public DogPark() {
+ //this.dogsInPark = new HashSet<>();
+ this.dogsInPark = new ArrayList<>();
+ }
+
+ public void play() {
+/*
+ for (Dog d : dogsInPark) {
+ System.out.printf("Dog %s is ", d); //uses override method in Dog.java for `d`
+ d.run();
+ }
+*/
+ Dog d1 = dogsInPark.get(0);
+ Dog d2 = dogsInPark.get(0);
+ if (d1.equals(d2)) {
+ System.out.printf("Dog %s is", d1);
+ d1.run();
+ System.out.printf("Dog %s is", d2);
+ d2.run();
+ }
+ }
+
+ public void dogEnter(Dog d) {
+ dogsInPark.add(d);
+ }
+
+ public static void main(String[] args) {
+
+ DogPark fortunaDp = new DogPark(); //Fortuna Dog Park
+
+ Dog dog1Object = new Dog("Bulldog", DogSize.LARGE,
+ new String[]{"light gray"}, 5, "Max");
+ Dog dog2Object = new Dog("Beagle", DogSize.MEDIUM,
+ new String[]{"Orange"}, 6, "Butch");
+ Dog dog3Object = new Dog("German Shepherd", DogSize.XTRALARGE,
+ new String[]{"White", "Orange"}, 6, "Kyle");
+
+ fortunaDp.dogEnter(dog1Object);
+ fortunaDp.dogEnter(dog2Object);
+ fortunaDp.play();
+ fortunaDp.dogEnter(dog3Object);
+ fortunaDp.play();
+
+
+ }
+
+}
diff --git a/src/DogSize.java b/src/DogSize.java
new file mode 100644
index 0000000..6e2beff
--- /dev/null
+++ b/src/DogSize.java
@@ -0,0 +1,6 @@
+public enum DogSize {
+ XTRALARGE,
+ LARGE,
+ MEDIUM,
+ SMALL
+}
diff --git a/src/Student.java b/src/Student.java
new file mode 100644
index 0000000..318aafe
--- /dev/null
+++ b/src/Student.java
@@ -0,0 +1,19 @@
+class Student { // Class name
+
+ private String name; // Instance Variable/field
+ private int rollNo; // Instance Variable/field
+
+ Student(String s, int r) { // Constructor (+ constructor parameters)
+ name = s; // instance variable gets value
+ rollNo = r; // instance variable gets value
+ }
+
+ void methodForDisplay() { // instance method
+ System.out.println(name+"'s Roll No: "+rollNo);
+ }
+
+ public static void main(String[] args) {
+ Student obj1=new Student("Rambo",21); // Student object gets created
+ obj1.methodForDisplay();
+ }
+}
\ No newline at end of file