diff --git a/.idea/misc.xml b/.idea/misc.xml
index 639900d..172df7b 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index bdef184..ecfb9b1 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,6 +2,7 @@
+
diff --git a/Dog/Dog.iml b/Dog/Dog.iml
new file mode 100644
index 0000000..c90834f
--- /dev/null
+++ b/Dog/Dog.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Dog/src/Dog.java b/Dog/src/Dog.java
new file mode 100644
index 0000000..e644a1b
--- /dev/null
+++ b/Dog/src/Dog.java
@@ -0,0 +1,45 @@
+public class Dog {
+ private String breed;
+ private String size;
+ private String color;
+ private int age;
+ private String dogName;
+ public Dog(String breed, String size, String color, int age, String dogName) {
+ this.breed = breed;
+ this.size = size;
+ this.color = color;
+ this.age = age;
+ this.dogName = dogName;
+ }
+ public void name() {
+ System.out.println("the "+ size +" and "+ color +" dog is a "+ breed +" named "+ dogName +" and is "+ age +" years old");
+ }
+ public void eat() {
+ System.out.println(dogName +" is eating.");
+ }
+ public void run(int distance) {
+ distance = 2 * age - distance;
+ if (distance < 0) {
+ distance = 0;
+ }
+ System.out.println(dogName +" ran "+ distance +" miles today.");
+ }
+ public void sleep() {
+ System.out.println(dogName +" is sleeping.");
+ }
+
+ public static void main(String[] args) {
+ Dog Dog1Object = new Dog("Bulldog", "large", "light gray", 5, "Meatloaf");
+ Dog Dog2Object = new Dog("Beagle", "large", "orange", 6, "Buddy");
+ Dog Dog3Object = new Dog("German Shepherd", "large", "white & orange", 6, "Chop");
+
+ Dog1Object.name();
+ Dog1Object.run(6);
+
+ Dog2Object.name();
+ Dog2Object.run(6);
+
+ Dog3Object.name();
+ Dog3Object.sleep();
+ }
+}
diff --git a/README.md b/README.md
index 833cd8b..dbbb7b3 100644
--- a/README.md
+++ b/README.md
@@ -10,24 +10,25 @@
6. All the instance methods for the class **Student**
```java
+//Class name: Student
class Student{
- private String name;
- private int rollNo;
-
+ private String name; //Instance variable/fields: name, data type is String
+ private int rollNo; //Instance variable/fields: rollNo, data type int
+ // Constructor: Parameters are (String s. int r)
Student(String s, int r)
{
- name = s;
- rollNo = r;
+ name = s; //instance variable name set to value of parameter s
+ rollNo = r; //instance variable rollNo set to value of parameter r
}
-
+ //instance method
void methodForDisplay()
{
- System.out.println(name+"'s Roll No: "+rollNo);
+ System.out.println(name+"'s Roll No: "+rollNo); //displays name and roll number
}
public static void main(String[] args) {
- Student obj1=new Student("Rambo",21);
- obj1.methodForDisplay();
+ Student obj1=new Student("Rambo",21); //Student object gets created here
+ obj1.methodForDisplay(); //calls instance method
}
}
```
@@ -35,8 +36,8 @@ class Student{
## Part 2 - Public VS Static
* 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.
-
+* In your own words, write a few sentences below explaining the difference between static and public methods in relation to a class.
+The main difference I notice between static and public methods are the way they are called. public methods require you to create an object to call it while static methods do not.
## Part 3 - Dogs
* View the image below, and from the image, construct a Java file **Dog** that mirrors the diagrammed class and the 3 dog objects.