Skip to content

Commit

Permalink
Merge pull request #99 from junnengsoo/feature/DeleteAnimalCommand
Browse files Browse the repository at this point in the history
Feature/delete animal command
  • Loading branch information
wjayee committed Nov 1, 2023
2 parents 69742fb + 4f7f9b8 commit 46253bb
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/main/java/seedu/address/logic/AnimalMessages.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public class AnimalMessages {
public static final String SEX = "Sex";
public static final String SPECIES = "Species";
public static final String BREED = "Breed";
public static final String DATE_OF_BIRTH = "Date of Birth";
public static final String DATE_OF_BIRTH = "; "; // to maintain SLAP
public static final String ADMISSION_DATE = "Date of Admission";
public static final String DISPLAY_FORMAT = "; %s:";
public static final String DISPLAY_FORMAT = "; %s: ";


/**
Expand Down Expand Up @@ -73,7 +73,7 @@ public static String format(Animal animal) {
.append(animal.getSpecies())
.append(String.format(DISPLAY_FORMAT, BREED))
.append(animal.getBreed())
.append(String.format(DISPLAY_FORMAT, DATE_OF_BIRTH))
.append(DATE_OF_BIRTH)
.append(animal.getDateOfBirth())
.append(String.format(DISPLAY_FORMAT, ADMISSION_DATE))
.append(animal.getAdmissionDate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import seedu.address.model.animal.Animal;

/**
* Adds a animal to the catalog.
* Adds an animal to the catalog.
*/

public class AddAnimalCommand extends AnimalCommand {
Expand All @@ -37,8 +37,8 @@ public class AddAnimalCommand extends AnimalCommand {
+ NAME.getPrefix() + "Pookie "
+ PET_ID.getPrefix() + "1234 "
+ SEX.getPrefix() + "MALE "
+ DATE_OF_BIRTH.getPrefix() + "01/01/2019 "
+ DATE_OF_ADMISSION.getPrefix() + "01/01/2019 "
+ DATE_OF_BIRTH.getPrefix() + "2023-01-01 "
+ DATE_OF_ADMISSION.getPrefix() + "2023-02-02 "
+ SPECIES.getPrefix() + "Dog "
+ BREED.getPrefix() + "Poodle";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import seedu.address.model.animal.Animal;

/**
* Deletes a person identified using it's displayed index from the address book.
* Deletes an animal identified using it's displayed index from the address book.
*/
public class DeleteAnimalCommand extends AnimalCommand {

Expand Down Expand Up @@ -43,7 +43,7 @@ public CommandResult execute(AnimalModel model) throws CommandException {

Animal animalToDelete = lastShownList.get(targetIndex.getZeroBased());
model.deleteAnimal(animalToDelete);
return new CommandResult(String.format(MESSAGE_DELETE_ANIMAL_SUCCESS, animalToDelete));
return new CommandResult(String.format(MESSAGE_DELETE_ANIMAL_SUCCESS, AnimalMessages.format(animalToDelete)));
}

@Override
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/seedu/address/logic/AnimalMessagesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ public void getErrorMessageForDuplicatePrefixes_singleDuplicatePrefix_returnErro
public void format_validAnimal_returnsFormattedString() {
Animal animal = new AnimalBuilder().build(); // Builds an Animal with default values.

String expectedOutput = animal.getName() + "; ID:" + animal.getPetId()
+ "; Sex:" + animal.getSex()
+ "; Species:" + animal.getSpecies()
+ "; Breed:" + animal.getBreed()
+ "; Date of Birth:" + animal.getDateOfBirth()
+ "; Date of Admission:" + animal.getAdmissionDate();
String expectedOutput = animal.getName() + "; ID: " + animal.getPetId()
+ "; Sex: " + animal.getSex()
+ "; Species: " + animal.getSpecies()
+ "; Breed: " + animal.getBreed()
+ "; " + animal.getDateOfBirth() // Remove repeat Date of Birth prefix
+ "; Date of Admission: " + animal.getAdmissionDate();

String formattedAnimal = AnimalMessages.format(animal);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import javafx.collections.FXCollections;
import seedu.address.commons.core.index.Index;
import seedu.address.logic.AnimalMessages;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.AnimalModel;
import seedu.address.model.animal.Animal;
Expand All @@ -31,7 +32,8 @@ public void execute_validIndex_success() throws CommandException {

DeleteAnimalCommand deleteAnimalCommand = new DeleteAnimalCommand(Index.fromOneBased(1));

String expectedMessage = String.format(DeleteAnimalCommand.MESSAGE_DELETE_ANIMAL_SUCCESS, dummyAnimal);
String expectedMessage = String.format(DeleteAnimalCommand.MESSAGE_DELETE_ANIMAL_SUCCESS,
AnimalMessages.format(dummyAnimal));

// Execute the command
CommandResult result = deleteAnimalCommand.execute(model);
Expand Down

0 comments on commit 46253bb

Please sign in to comment.