From 0b481900fd3ce7b05a69fdbf344f27d57cb61c53 Mon Sep 17 00:00:00 2001 From: Abubakaryounis97 Date: Mon, 21 Jul 2025 11:20:11 -0400 Subject: [PATCH 1/3] first push --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6eb8bba..d85e189 100644 --- a/README.md +++ b/README.md @@ -72,3 +72,5 @@ * `Integer getNumberOfPets()` * `String getName()` * `Pet[] getPets()` + +hello \ No newline at end of file From 3f187a43247d580314120c9c7b3374f9cbffe693 Mon Sep 17 00:00:00 2001 From: Abubakaryounis97 Date: Mon, 21 Jul 2025 11:47:28 -0400 Subject: [PATCH 2/3] Implement constructors and methods in Pet class to initialize attributes and manage ownership --- .../zipcodewilmington/assessment1/Cat.java | 1 + .../zipcodewilmington/assessment1/Pet.java | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/zipcodewilmington/assessment1/Cat.java b/src/main/java/com/zipcodewilmington/assessment1/Cat.java index 1cf2894..6d9cbcd 100644 --- a/src/main/java/com/zipcodewilmington/assessment1/Cat.java +++ b/src/main/java/com/zipcodewilmington/assessment1/Cat.java @@ -10,6 +10,7 @@ public class Cat extends Pet { */ public Cat(String name, Integer age) { + } /** diff --git a/src/main/java/com/zipcodewilmington/assessment1/Pet.java b/src/main/java/com/zipcodewilmington/assessment1/Pet.java index afc3e99..c850983 100644 --- a/src/main/java/com/zipcodewilmington/assessment1/Pet.java +++ b/src/main/java/com/zipcodewilmington/assessment1/Pet.java @@ -8,6 +8,10 @@ public abstract class Pet implements Animal { * nullary constructor * by default, pet has age of 0; name of ""; */ + private String name; + private Integer age; + private PetOwner owner; + public Pet() { } @@ -15,6 +19,7 @@ public Pet() { * @param name name of this pet */ public Pet(String name) { + this.name=""; } @@ -22,6 +27,7 @@ public Pet(String name) { * @param age age of this pet */ public Pet(int age) { + this.age=0; } /** @@ -29,20 +35,23 @@ public Pet(int age) { * @param age age of this pet */ public Pet(String name, int age) { + this.name=""; + this.age=0; } /** * @return name of this pet */ public String getName() { - return null; + + return name; } /** * @return age of this pet */ public Integer getAge() { - return null; + return age; } /** @@ -50,12 +59,16 @@ public Integer getAge() { * ensure this instance of `Pet` is added to the owner's composite `pets` list */ public void setOwner(PetOwner newPetOwner) { + + this.owner = newPetOwner; + newPetOwner.addPet(this); + } /** * @return PetOwner object whose composite `pets` collection contains this Pet instance */ public PetOwner getOwner() { - return null; + return this.owner; } } From 7b62038e30f58359bb7b7a017766d17ac1b7e612 Mon Sep 17 00:00:00 2001 From: Abubakaryounis97 Date: Mon, 21 Jul 2025 11:59:08 -0400 Subject: [PATCH 3/3] Refactor Pet and PetOwner classes for improved readability --- src/main/java/com/zipcodewilmington/assessment1/Pet.java | 2 +- .../java/com/zipcodewilmington/assessment1/PetOwner.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/zipcodewilmington/assessment1/Pet.java b/src/main/java/com/zipcodewilmington/assessment1/Pet.java index c850983..220f592 100644 --- a/src/main/java/com/zipcodewilmington/assessment1/Pet.java +++ b/src/main/java/com/zipcodewilmington/assessment1/Pet.java @@ -69,6 +69,6 @@ public void setOwner(PetOwner newPetOwner) { * @return PetOwner object whose composite `pets` collection contains this Pet instance */ public PetOwner getOwner() { - return this.owner; + return owner; } } diff --git a/src/main/java/com/zipcodewilmington/assessment1/PetOwner.java b/src/main/java/com/zipcodewilmington/assessment1/PetOwner.java index 326ada5..f49844f 100644 --- a/src/main/java/com/zipcodewilmington/assessment1/PetOwner.java +++ b/src/main/java/com/zipcodewilmington/assessment1/PetOwner.java @@ -8,7 +8,11 @@ public class PetOwner { * @param name name of the owner of the Pet * @param pets array of Pet object */ - public PetOwner(String name, Pet... pets) { + + public PetOwner(String name, Pet... pets) + { + + } /**