Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/main/java/com/zipcodewilmington/assessment1/Cat.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,21 @@ public class Cat extends Pet {
* @param age age of this Cat
*/
public Cat(String name, Integer age) {

super(name, age);
}

/**
* @param age age of this Cat
*/
public Cat(Integer age) {
super(age);
}

/**
* @param name name of this Cat
*/
public Cat(String name) {

super(name);
}

/**
Expand All @@ -32,12 +33,13 @@ public Cat(String name) {
* age is 0
*/
public Cat() {

}

/**
* @return meow as a string
*/
public String speak() {
return null;
return "meow";
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/zipcodewilmington/assessment1/Dog.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ public Dog() {
* @return bark as a string
*/
public String speak() {
return null;
return "bark";
}
}
17 changes: 14 additions & 3 deletions src/main/java/com/zipcodewilmington/assessment1/Pet.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,64 @@ public abstract class Pet implements Animal {
* by default, pet has age of 0; name of "";
*/
public Pet() {
String name = "";
int age = 0;
}

/**
* @param name name of this pet
*/
public Pet(String name) {
this.name = name;
this.age = 0;

}


/**
* @param age age of this pet
*/
public Pet(int age) {
this.age = age;
this.name = "";

}

/**
* @param name name of this pet
* @param age age of this pet
*/
public Pet(String name, int age) {
String name = name;
int age = age;
}

/**
* @return name of this pet
*/
public String getName() {
return null;
return name;
}

/**
* @return age of this pet
*/
public Integer getAge() {
return null;
return age;
}

/**
* @param newPetOwner the new owner of this pet
* ensure this instance of `Pet` is added to the owner's composite `pets` list
*/
public void setOwner(PetOwner newPetOwner) {
this.PetOwner = newPetOwner;
}

/**
* @return PetOwner object whose composite `pets` collection contains this Pet instance
*/
public PetOwner getOwner() {
return null;
return petOwner;
}
}
7 changes: 5 additions & 2 deletions src/main/java/com/zipcodewilmington/assessment1/PetOwner.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ public class PetOwner {
* @param pets array of Pet object
*/
public PetOwner(String name, Pet... pets) {
this.name = name;
this.Pets = pets;
}

/**
* @param pet pet to be added to the composite collection of Pets
*/
public void addPet(Pet pet) {
this.Pets.add(pet);
}

/**
Expand Down Expand Up @@ -68,13 +71,13 @@ public Integer getNumberOfPets() {
* @return the name property of the Pet
*/
public String getName() {
return null;
return name;
}

/**
* @return array representation of animals owned by this PetOwner
*/
public Pet[] getPets() {
return null;
return Pets;
}
}