Skip to content

Commit

Permalink
Merge pull request #225 from marekpinto/master
Browse files Browse the repository at this point in the history
Add Assert Statements
  • Loading branch information
shawntangy authored Apr 10, 2023
2 parents f5cbc44 + 45219b4 commit 21f6f65
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/main/java/seedu/pettracker/data/PetList.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public static void addPet(String petName) throws EmptyPetNameException, Duplicat
}

private static int find(String petName) {
assert petList != null;
for (int i = 0; i < petList.size(); i++) {
if (petList.get(i).getPetName().equals(petName)) {
return i;
Expand All @@ -55,6 +56,7 @@ private static int find(String petName) {
}

private static Pet get(int index) {
assert index > -1;
return petList.get(index);
}

Expand All @@ -64,8 +66,10 @@ private static Pet get(int index) {
* @param petName Name of pet to edit
* @param statName Name of stat to add
* @param statValue New stat Value
* @throws NumberFormatException When stat is Age/Weight and is not a number
* @throws NonPositiveIntegerException When stat is Age/Weight and is non-positive
* @throws NumberFormatException When stat is Age/Weight and is not a
* number
* @throws NonPositiveIntegerException When stat is Age/Weight and is
* non-positive
* @throws InvalidStatException When stat is not Type/Age/Weight
* @throws PetNotFoundException When Pet is not in PetList
*/
Expand Down Expand Up @@ -145,6 +149,7 @@ public static void list() {

/**
* Return the number of pets in the PetList.
*
*
* @return number of pets in the list.
*/
Expand All @@ -153,13 +158,16 @@ public static int getNumberOfPets() {
}

/**
* Edit pet stats of a pet in the PetList to change the previous value to a new value
* Edit pet stats of a pet in the PetList to change the previous value to a new
* value
*
* @param petName Name of pet to edit
* @param stat Name of stat to edit
* @param newValue New stat Value
* @throws NonPositiveIntegerException When stat is Age/Weight and is non-positive
* @throws NumberFormatException When stat is Age/Weight and is not a number
* @throws NonPositiveIntegerException When stat is Age/Weight and is
* non-positive
* @throws NumberFormatException When stat is Age/Weight and is not a
* number
* @throws InvalidStatException When stat is not Type/Age/Weight
* @throws PetNotFoundException When Pet is not in PetList
*/
Expand Down

0 comments on commit 21f6f65

Please sign in to comment.