From a67468aebb43284a07e4f61525a9e9b2f0e407ea Mon Sep 17 00:00:00 2001 From: nramapurath Date: Wed, 8 Mar 2023 19:00:25 +0800 Subject: [PATCH] Rename Person to Patient in all files --- LICENSE | 4 +- docs/DeveloperGuide.md | 18 +-- docs/UserGuide.md | 4 +- docs/tutorials/AddRemark.md | 38 ++--- docs/tutorials/RemovingFields.md | 4 +- docs/tutorials/TracingCode.md | 20 +-- .../seedu/address/commons/core/Messages.java | 2 +- src/main/java/seedu/address/logic/Logic.java | 4 +- .../seedu/address/logic/LogicManager.java | 4 +- .../address/logic/commands/AddCommand.java | 20 +-- .../address/logic/commands/DeleteCommand.java | 16 +- .../address/logic/commands/EditCommand.java | 58 ++++---- .../address/logic/commands/FindCommand.java | 2 +- .../logic/parser/AddCommandParser.java | 14 +- .../logic/parser/FindCommandParser.java | 2 +- .../address/logic/parser/ParserUtil.java | 8 +- .../java/seedu/address/model/AddressBook.java | 42 +++--- src/main/java/seedu/address/model/Model.java | 34 ++--- .../seedu/address/model/ModelManager.java | 38 ++--- .../address/model/ReadOnlyAddressBook.java | 4 +- .../model/{person => patient}/Address.java | 4 +- .../model/{person => patient}/Email.java | 4 +- .../model/{person => patient}/Name.java | 4 +- .../NameContainsKeywordsPredicate.java | 10 +- .../Person.java => patient/Patient.java} | 30 ++-- .../model/{person => patient}/Phone.java | 4 +- .../model/patient/UniquePersonList.java | 137 ++++++++++++++++++ .../exceptions/DuplicatePersonException.java | 2 +- .../exceptions/PersonNotFoundException.java | 6 + .../model/person/UniquePersonList.java | 137 ------------------ .../exceptions/PersonNotFoundException.java | 6 - .../address/model/util/SampleDataUtil.java | 27 ++-- .../address/storage/JsonAdaptedPerson.java | 28 ++-- .../storage/JsonSerializableAddressBook.java | 10 +- .../java/seedu/address/ui/PersonCard.java | 24 +-- .../seedu/address/ui/PersonListPanel.java | 20 +-- src/main/resources/view/MainWindow.fxml | 2 +- .../seedu/address/logic/LogicManagerTest.java | 6 +- .../commands/AddCommandIntegrationTest.java | 14 +- .../logic/commands/AddCommandTest.java | 66 ++++----- .../logic/commands/CommandTestUtil.java | 14 +- .../logic/commands/DeleteCommandTest.java | 16 +- .../logic/commands/EditCommandTest.java | 42 +++--- ...st.java => EditPatientDescriptorTest.java} | 2 +- .../logic/commands/FindCommandTest.java | 4 +- .../logic/parser/AddCommandParserTest.java | 27 ++-- .../logic/parser/AddressBookParserTest.java | 14 +- .../logic/parser/EditCommandParserTest.java | 10 +- .../logic/parser/FindCommandParserTest.java | 2 +- .../address/logic/parser/ParserUtilTest.java | 8 +- .../seedu/address/model/AddressBookTest.java | 26 ++-- .../seedu/address/model/ModelManagerTest.java | 2 +- .../{person => patient}/AddressTest.java | 2 +- .../model/{person => patient}/EmailTest.java | 2 +- .../NameContainsKeywordsPredicateTest.java | 4 +- .../model/{person => patient}/NameTest.java | 2 +- .../PatientTest.java} | 18 +-- .../model/{person => patient}/PhoneTest.java | 2 +- .../UniquePatientListTest.java} | 22 +-- ...nTest.java => JsonAdaptedPatientTest.java} | 10 +- .../address/testutil/AddressBookBuilder.java | 8 +- .../testutil/EditPersonDescriptorBuilder.java | 24 +-- .../seedu/address/testutil/PersonBuilder.java | 40 ++--- .../seedu/address/testutil/PersonUtil.java | 24 +-- .../java/seedu/address/testutil/TestUtil.java | 10 +- .../address/testutil/TypicalPersons.java | 34 ++--- 66 files changed, 620 insertions(+), 626 deletions(-) rename src/main/java/seedu/address/model/{person => patient}/Address.java (94%) rename src/main/java/seedu/address/model/{person => patient}/Email.java (96%) rename src/main/java/seedu/address/model/{person => patient}/Name.java (94%) rename src/main/java/seedu/address/model/{person => patient}/NameContainsKeywordsPredicate.java (77%) rename src/main/java/seedu/address/model/{person/Person.java => patient/Patient.java} (76%) rename src/main/java/seedu/address/model/{person => patient}/Phone.java (93%) create mode 100644 src/main/java/seedu/address/model/patient/UniquePersonList.java rename src/main/java/seedu/address/model/{person => patient}/exceptions/DuplicatePersonException.java (86%) create mode 100644 src/main/java/seedu/address/model/patient/exceptions/PersonNotFoundException.java delete mode 100644 src/main/java/seedu/address/model/person/UniquePersonList.java delete mode 100644 src/main/java/seedu/address/model/person/exceptions/PersonNotFoundException.java rename src/test/java/seedu/address/logic/commands/{EditPersonDescriptorTest.java => EditPatientDescriptorTest.java} (98%) rename src/test/java/seedu/address/model/{person => patient}/AddressTest.java (97%) rename src/test/java/seedu/address/model/{person => patient}/EmailTest.java (99%) rename src/test/java/seedu/address/model/{person => patient}/NameContainsKeywordsPredicateTest.java (97%) rename src/test/java/seedu/address/model/{person => patient}/NameTest.java (97%) rename src/test/java/seedu/address/model/{person/PersonTest.java => patient/PatientTest.java} (85%) rename src/test/java/seedu/address/model/{person => patient}/PhoneTest.java (97%) rename src/test/java/seedu/address/model/{person/UniquePersonListTest.java => patient/UniquePatientListTest.java} (88%) rename src/test/java/seedu/address/storage/{JsonAdaptedPersonTest.java => JsonAdaptedPatientTest.java} (96%) diff --git a/LICENSE b/LICENSE index 39b3478982c..c42f359e055 100644 --- a/LICENSE +++ b/LICENSE @@ -2,11 +2,11 @@ MIT License Copyright (c) 2016 Software Engineering Education - FOSS Resources -Permission is hereby granted, free of charge, to any person obtaining a copy +Permission is hereby granted, free of charge, to any patient obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is +copies of the Software, and to permit patients to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index e5ab3441863..f8f6ea03b80 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -95,7 +95,7 @@ Here's a (partial) class diagram of the `Logic` component: How the `Logic` component works: 1. When `Logic` is called upon to execute a command, it uses the `AddressBookParser` class to parse the user command. 1. This results in a `Command` object (more precisely, an object of one of its subclasses e.g., `AddCommand`) which is executed by the `LogicManager`. -1. The command can communicate with the `Model` when it is executed (e.g. to add a person). +1. The command can communicate with the `Model` when it is executed (e.g. to add a patient). 1. The result of the command execution is encapsulated as a `CommandResult` object which is returned back from `Logic`. The Sequence Diagram below illustrates the interactions within the `Logic` component for the `execute("delete 1")` API call. @@ -172,11 +172,11 @@ Step 1. The user launches the application for the first time. The `VersionedAddr ![UndoRedoState0](images/UndoRedoState0.png) -Step 2. The user executes `delete 5` command to delete the 5th person in the address book. The `delete` command calls `Model#commitAddressBook()`, causing the modified state of the address book after the `delete 5` command executes to be saved in the `addressBookStateList`, and the `currentStatePointer` is shifted to the newly inserted address book state. +Step 2. The user executes `delete 5` command to delete the 5th patient in the address book. The `delete` command calls `Model#commitAddressBook()`, causing the modified state of the address book after the `delete 5` command executes to be saved in the `addressBookStateList`, and the `currentStatePointer` is shifted to the newly inserted address book state. ![UndoRedoState1](images/UndoRedoState1.png) -Step 3. The user executes `add n/David …​` to add a new person. The `add` command also calls `Model#commitAddressBook()`, causing another modified address book state to be saved into the `addressBookStateList`. +Step 3. The user executes `add n/David …​` to add a new patient. The `add` command also calls `Model#commitAddressBook()`, causing another modified address book state to be saved into the `addressBookStateList`. ![UndoRedoState2](images/UndoRedoState2.png) @@ -184,7 +184,7 @@ Step 3. The user executes `add n/David …​` to add a new person. The `add` co -Step 4. The user now decides that adding the person was a mistake, and decides to undo that action by executing the `undo` command. The `undo` command will call `Model#undoAddressBook()`, which will shift the `currentStatePointer` once to the left, pointing it to the previous address book state, and restores the address book to that state. +Step 4. The user now decides that adding the patient was a mistake, and decides to undo that action by executing the `undo` command. The `undo` command will call `Model#undoAddressBook()`, which will shift the `currentStatePointer` once to the left, pointing it to the previous address book state, and restores the address book to that state. ![UndoRedoState3](images/UndoRedoState3.png) @@ -229,7 +229,7 @@ The following activity diagram summarizes what happens when a user executes a ne * **Alternative 2:** Individual command knows how to undo/redo by itself. - * Pros: Will use less memory (e.g. for `delete`, just save the person being deleted). + * Pros: Will use less memory (e.g. for `delete`, just save the patient being deleted). * Cons: We must ensure that the implementation of each individual command are correct. _{more aspects and alternatives to be added}_ @@ -381,17 +381,17 @@ testers are expected to do more *exploratory* testing. 1. _{ more test cases …​ }_ -### Deleting a person +### Deleting a patient -1. Deleting a person while all persons are being shown +1. Deleting a patient while all patients are being shown - 1. Prerequisites: List all persons using the `list` command. Multiple persons in the list. + 1. Prerequisites: List all patients using the `list` command. Multiple patients in the list. 1. Test case: `delete 1`
Expected: First contact is deleted from the list. Details of the deleted contact shown in the status message. Timestamp in the status bar is updated. 1. Test case: `delete 0`
- Expected: No person is deleted. Error details shown in the status message. Status bar remains the same. + Expected: No patient is deleted. Error details shown in the status message. Status bar remains the same. 1. Other incorrect delete commands to try: `delete`, `delete x`, `...` (where x is larger than the list size)
Expected: Similar to previous. diff --git a/docs/UserGuide.md b/docs/UserGuide.md index a6fe53c8e7a..5f780687d55 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -81,7 +81,7 @@ Format: `add nric/NRIC name/NAME cond/CONDITION​` Examples: @@ -129,7 +129,7 @@ Delete patient by NRIC. Format: `delete nric/NRIC` -- Deletes the person at the specified `NRIC`. +- Deletes the patient at the specified `NRIC`. Examples: diff --git a/docs/tutorials/AddRemark.md b/docs/tutorials/AddRemark.md index 880c701042f..7670f8c0ea0 100644 --- a/docs/tutorials/AddRemark.md +++ b/docs/tutorials/AddRemark.md @@ -28,7 +28,7 @@ package seedu.address.logic.commands; import seedu.address.model.Model; /** - * Changes the remark of an existing person in the address book. + * Changes the remark of an existing patient in the address book. */ public class RemarkCommand extends Command { @@ -65,8 +65,8 @@ Following the convention in other commands, we add relevant messages as constant ``` java public static final String MESSAGE_USAGE = COMMAND_WORD - + ": Edits the remark of the person identified " - + "by the index number used in the last person listing. " + + ": Edits the remark of the patient identified " + + "by the index number used in the last patient listing. " + "Existing remark will be overwritten by the input.\n" + "Parameters: INDEX (must be a positive integer) " + "r/ [REMARK]\n" @@ -101,8 +101,8 @@ public class RemarkCommand extends Command { private final String remark; /** - * @param index of the person in the filtered person list to edit the remark - * @param remark of the person to be updated to + * @param index of the patient in the filtered patient list to edit the remark + * @param remark of the patient to be updated to */ public RemarkCommand(Index index, String remark) { requireAllNonNull(index, remark); @@ -225,11 +225,11 @@ If you are stuck, check out the sample ## Add `Remark` to the model -Now that we have all the information that we need, let’s lay the groundwork for propagating the remarks added into the in-memory storage of person data. We achieve that by working with the `Person` model. Each field in a Person is implemented as a separate class (e.g. a `Name` object represents the person’s name). That means we should add a `Remark` class so that we can use a `Remark` object to represent a remark given to a person. +Now that we have all the information that we need, let’s lay the groundwork for propagating the remarks added into the in-memory storage of patient data. We achieve that by working with the `Person` model. Each field in a Person is implemented as a separate class (e.g. a `Name` object represents the patient’s name). That means we should add a `Remark` class so that we can use a `Remark` object to represent a remark given to a patient. ### Add a new `Remark` class -Create a new `Remark` in `seedu.address.model.person`. Since a `Remark` is a field that is similar to `Address`, we can reuse a significant bit of code. +Create a new `Remark` in `seedu.address.model.patient`. Since a `Remark` is a field that is similar to `Address`, we can reuse a significant bit of code. A copy-paste and search-replace later, you should have something like [this](https://github.com/se-edu/addressbook-level3/commit/4516e099699baa9e2d51801bd26f016d812dedcc#diff-41bb13c581e280c686198251ad6cc337cd5e27032772f06ed9bf7f1440995ece). Note how `Remark` has no constrains and thus does not require input validation. @@ -240,7 +240,7 @@ Let’s change `RemarkCommand` and `RemarkCommandParser` to use the new `Remark` ## Add a placeholder element for remark to the UI -Without getting too deep into `fxml`, let’s go on a 5 minute adventure to get some placeholder text to show up for each person. +Without getting too deep into `fxml`, let’s go on a 5 minute adventure to get some placeholder text to show up for each patient. Simply add the following to [`seedu.address.ui.PersonCard`](https://github.com/se-edu/addressbook-level3/commit/850b78879582f38accb05dd20c245963c65ea599#diff-639834f1e05afe2276a86372adf0fe5f69314642c2d93cfa543d614ce5a76688). @@ -311,9 +311,9 @@ Just add [this one line of code!](https://github.com/se-edu/addressbook-level3/c **`PersonCard.java`:** ``` java -public PersonCard(Person person, int displayedIndex) { +public PersonCard(Person patient, int displayedIndex) { //... - remark.setText(person.getRemark().value); + remark.setText(patient.getRemark().value); } ``` @@ -343,25 +343,25 @@ save it with `Model#setPerson()`. throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); } - Person personToEdit = lastShownList.get(index.getZeroBased()); - Person editedPerson = new Person( - personToEdit.getName(), personToEdit.getPhone(), personToEdit.getEmail(), - personToEdit.getAddress(), remark, personToEdit.getTags()); + Person patientToEdit = lastShownList.get(index.getZeroBased()); + Person editedPatient = new Person( + patientToEdit.getName(), patientToEdit.getPhone(), patientToEdit.getEmail(), + patientToEdit.getAddress(), remark, patientToEdit.getTags()); - model.setPerson(personToEdit, editedPerson); + model.setPerson(patientToEdit, editedPatient); model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); - return new CommandResult(generateSuccessMessage(editedPerson)); + return new CommandResult(generateSuccessMessage(editedPatient)); } /** * Generates a command execution success message based on whether * the remark is added to or removed from - * {@code personToEdit}. + * {@code patientToEdit}. */ - private String generateSuccessMessage(Person personToEdit) { + private String generateSuccessMessage(Person patientToEdit) { String message = !remark.value.isEmpty() ? MESSAGE_ADD_REMARK_SUCCESS : MESSAGE_DELETE_REMARK_SUCCESS; - return String.format(message, personToEdit); + return String.format(message, patientToEdit); } ``` diff --git a/docs/tutorials/RemovingFields.md b/docs/tutorials/RemovingFields.md index f29169bc924..6a27d729077 100644 --- a/docs/tutorials/RemovingFields.md +++ b/docs/tutorials/RemovingFields.md @@ -28,7 +28,7 @@ IntelliJ IDEA provides a refactoring tool that can identify *most* parts of a re ### Assisted refactoring -The `address` field in `Person` is actually an instance of the `seedu.address.model.person.Address` class. Since removing the `Address` class will break the application, we start by identifying `Address`'s usages. This allows us to see code that depends on `Address` to function properly and edit them on a case-by-case basis. Right-click the `Address` class and select `Refactor` \> `Safe Delete` through the menu. +The `address` field in `Person` is actually an instance of the `seedu.address.model.patient.Address` class. Since removing the `Address` class will break the application, we start by identifying `Address`'s usages. This allows us to see code that depends on `Address` to function properly and edit them on a case-by-case basis. Right-click the `Address` class and select `Refactor` \> `Safe Delete` through the menu. * :bulb: To make things simpler, you can unselect the options `Search in comments and strings` and `Search for text occurrences` ![Usages detected](../images/remove/UnsafeDelete.png) @@ -100,7 +100,7 @@ In `src/test/data/`, data meant for testing purposes are stored. While keeping t ```json { - "persons": [ { + "patients": [ { "name": "Person with invalid name field: Ha!ns Mu@ster", "phone": "9482424", "email": "hans@example.com", diff --git a/docs/tutorials/TracingCode.md b/docs/tutorials/TracingCode.md index 4fb62a83ef6..9b1725ca825 100644 --- a/docs/tutorials/TracingCode.md +++ b/docs/tutorials/TracingCode.md @@ -189,22 +189,22 @@ Recall from the User Guide that the `edit` command has the format: `edit INDEX [ @Override public CommandResult execute(Model model) throws CommandException { ... - Person personToEdit = lastShownList.get(index.getZeroBased()); - Person editedPerson = createEditedPerson(personToEdit, editPersonDescriptor); - if (!personToEdit.isSamePerson(editedPerson) && model.hasPerson(editedPerson)) { + Person patientToEdit = lastShownList.get(index.getZeroBased()); + Person editedPatient = createEditedPerson(patientToEdit, editPersonDescriptor); + if (!patientToEdit.isSamePerson(editedPatient) && model.hasPerson(editedPatient)) { throw new CommandException(MESSAGE_DUPLICATE_PERSON); } - model.setPerson(personToEdit, editedPerson); + model.setPerson(patientToEdit, editedPatient); model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); - return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, editedPerson)); + return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, editedPatient)); } ``` 1. As suspected, `command#execute()` does indeed make changes to the `model` object. Specifically, - * it uses the `setPerson()` method (defined in the interface `Model` and implemented in `ModelManager` as per the usual pattern) to update the person data. - * it uses the `updateFilteredPersonList` method to ask the `Model` to populate the 'filtered list' with _all_ persons.
- FYI, The 'filtered list' is the list of persons resulting from the most recent operation that will be shown to the user immediately after. For the `edit` command, we populate it with all the persons so that the user can see the edited person along with all other persons. If this was a `find` command, we would be setting that list to contain the search results instead.
- To provide some context, given below is the class diagram of the `Model` component. See if you can figure out where the 'filtered list' of persons is being tracked. + * it uses the `setPerson()` method (defined in the interface `Model` and implemented in `ModelManager` as per the usual pattern) to update the patient data. + * it uses the `updateFilteredPersonList` method to ask the `Model` to populate the 'filtered list' with _all_ patients.
+ FYI, The 'filtered list' is the list of patients resulting from the most recent operation that will be shown to the user immediately after. For the `edit` command, we populate it with all the patients so that the user can see the edited patient along with all other patients. If this was a `find` command, we would be setting that list to contain the search results instead.
+ To provide some context, given below is the class diagram of the `Model` component. See if you can figure out where the 'filtered list' of patients is being tracked.
* :bulb: This may be a good time to read through the [`Model` component section of the DG](../DeveloperGuide.html#model-component) @@ -231,7 +231,7 @@ Recall from the User Guide that the `edit` command has the format: `edit INDEX [ * {@code JsonSerializableAddressBook}. */ public JsonSerializableAddressBook(ReadOnlyAddressBook source) { - persons.addAll( + patients.addAll( source.getPersonList() .stream() .map(JsonAdaptedPerson::new) diff --git a/src/main/java/seedu/address/commons/core/Messages.java b/src/main/java/seedu/address/commons/core/Messages.java index 1deb3a1e469..9c8195dfaff 100644 --- a/src/main/java/seedu/address/commons/core/Messages.java +++ b/src/main/java/seedu/address/commons/core/Messages.java @@ -7,7 +7,7 @@ public class Messages { public static final String MESSAGE_UNKNOWN_COMMAND = "Unknown command"; public static final String MESSAGE_INVALID_COMMAND_FORMAT = "Invalid command format! \n%1$s"; - public static final String MESSAGE_INVALID_PERSON_DISPLAYED_INDEX = "The person index provided is invalid"; + public static final String MESSAGE_INVALID_PERSON_DISPLAYED_INDEX = "The patient index provided is invalid"; public static final String MESSAGE_PERSONS_LISTED_OVERVIEW = "%1$d persons listed!"; } diff --git a/src/main/java/seedu/address/logic/Logic.java b/src/main/java/seedu/address/logic/Logic.java index 92cd8fa605a..065b8002646 100644 --- a/src/main/java/seedu/address/logic/Logic.java +++ b/src/main/java/seedu/address/logic/Logic.java @@ -8,7 +8,7 @@ import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.ReadOnlyAddressBook; -import seedu.address.model.person.Person; +import seedu.address.model.patient.Patient; /** * API of the Logic component @@ -31,7 +31,7 @@ public interface Logic { ReadOnlyAddressBook getAddressBook(); /** Returns an unmodifiable view of the filtered list of persons */ - ObservableList getFilteredPersonList(); + ObservableList getFilteredPersonList(); /** * Returns the user prefs' address book file path. diff --git a/src/main/java/seedu/address/logic/LogicManager.java b/src/main/java/seedu/address/logic/LogicManager.java index 9d9c6d15bdc..bf22ecaee4b 100644 --- a/src/main/java/seedu/address/logic/LogicManager.java +++ b/src/main/java/seedu/address/logic/LogicManager.java @@ -14,7 +14,7 @@ import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.Model; import seedu.address.model.ReadOnlyAddressBook; -import seedu.address.model.person.Person; +import seedu.address.model.patient.Patient; import seedu.address.storage.Storage; /** @@ -60,7 +60,7 @@ public ReadOnlyAddressBook getAddressBook() { } @Override - public ObservableList getFilteredPersonList() { + public ObservableList getFilteredPersonList() { return model.getFilteredPersonList(); } diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index 71656d7c5c8..df29182b7d8 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -9,16 +9,16 @@ import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.Model; -import seedu.address.model.person.Person; +import seedu.address.model.patient.Patient; /** - * Adds a person to the address book. + * Adds a patient to the address book. */ public class AddCommand extends Command { public static final String COMMAND_WORD = "add"; - public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to the address book. " + public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a patient to the address book. " + "Parameters: " + PREFIX_NAME + "NAME " + PREFIX_PHONE + "PHONE " @@ -33,17 +33,17 @@ public class AddCommand extends Command { + PREFIX_TAG + "friends " + PREFIX_TAG + "owesMoney"; - public static final String MESSAGE_SUCCESS = "New person added: %1$s"; - public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book"; + public static final String MESSAGE_SUCCESS = "New patient added: %1$s"; + public static final String MESSAGE_DUPLICATE_PERSON = "This patient already exists in the address book"; - private final Person toAdd; + private final Patient toAdd; /** - * Creates an AddCommand to add the specified {@code Person} + * Creates an AddCommand to add the specified {@code Patient} */ - public AddCommand(Person person) { - requireNonNull(person); - toAdd = person; + public AddCommand(Patient patient) { + requireNonNull(patient); + toAdd = patient; } @Override diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeleteCommand.java index 02fd256acba..cd6b765df09 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java @@ -8,21 +8,21 @@ import seedu.address.commons.core.index.Index; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.Model; -import seedu.address.model.person.Person; +import seedu.address.model.patient.Patient; /** - * Deletes a person identified using it's displayed index from the address book. + * Deletes a patient identified using it's displayed index from the address book. */ public class DeleteCommand extends Command { public static final String COMMAND_WORD = "delete"; public static final String MESSAGE_USAGE = COMMAND_WORD - + ": Deletes the person identified by the index number used in the displayed person list.\n" + + ": Deletes the patient identified by the index number used in the displayed patient list.\n" + "Parameters: INDEX (must be a positive integer)\n" + "Example: " + COMMAND_WORD + " 1"; - public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Deleted Person: %1$s"; + public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Deleted Patient: %1$s"; private final Index targetIndex; @@ -33,15 +33,15 @@ public DeleteCommand(Index targetIndex) { @Override public CommandResult execute(Model model) throws CommandException { requireNonNull(model); - List lastShownList = model.getFilteredPersonList(); + List lastShownList = model.getFilteredPersonList(); if (targetIndex.getZeroBased() >= lastShownList.size()) { throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); } - Person personToDelete = lastShownList.get(targetIndex.getZeroBased()); - model.deletePerson(personToDelete); - return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, personToDelete)); + Patient patientToDelete = lastShownList.get(targetIndex.getZeroBased()); + model.deletePerson(patientToDelete); + return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, patientToDelete)); } @Override diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index 7e36114902f..2bdad1d4640 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -19,22 +19,22 @@ import seedu.address.commons.util.CollectionUtil; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.Model; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Person; -import seedu.address.model.person.Phone; +import seedu.address.model.patient.Address; +import seedu.address.model.patient.Email; +import seedu.address.model.patient.Name; +import seedu.address.model.patient.Patient; +import seedu.address.model.patient.Phone; import seedu.address.model.tag.Tag; /** - * Edits the details of an existing person in the address book. + * Edits the details of an existing patient in the address book. */ public class EditCommand extends Command { public static final String COMMAND_WORD = "edit"; - public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the person identified " - + "by the index number used in the displayed person list. " + public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the patient identified " + + "by the index number used in the displayed patient list. " + "Existing values will be overwritten by the input values.\n" + "Parameters: INDEX (must be a positive integer) " + "[" + PREFIX_NAME + "NAME] " @@ -46,16 +46,16 @@ public class EditCommand extends Command { + PREFIX_PHONE + "91234567 " + PREFIX_EMAIL + "johndoe@example.com"; - public static final String MESSAGE_EDIT_PERSON_SUCCESS = "Edited Person: %1$s"; + public static final String MESSAGE_EDIT_PERSON_SUCCESS = "Edited Patient: %1$s"; public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided."; - public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book."; + public static final String MESSAGE_DUPLICATE_PERSON = "This patient already exists in the address book."; private final Index index; private final EditPersonDescriptor editPersonDescriptor; /** - * @param index of the person in the filtered person list to edit - * @param editPersonDescriptor details to edit the person with + * @param index of the patient in the filtered patient list to edit + * @param editPersonDescriptor details to edit the patient with */ public EditCommand(Index index, EditPersonDescriptor editPersonDescriptor) { requireNonNull(index); @@ -68,38 +68,38 @@ public EditCommand(Index index, EditPersonDescriptor editPersonDescriptor) { @Override public CommandResult execute(Model model) throws CommandException { requireNonNull(model); - List lastShownList = model.getFilteredPersonList(); + List lastShownList = model.getFilteredPersonList(); if (index.getZeroBased() >= lastShownList.size()) { throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); } - Person personToEdit = lastShownList.get(index.getZeroBased()); - Person editedPerson = createEditedPerson(personToEdit, editPersonDescriptor); + Patient patientToEdit = lastShownList.get(index.getZeroBased()); + Patient editedPatient = createEditedPerson(patientToEdit, editPersonDescriptor); - if (!personToEdit.isSamePerson(editedPerson) && model.hasPerson(editedPerson)) { + if (!patientToEdit.isSamePerson(editedPatient) && model.hasPerson(editedPatient)) { throw new CommandException(MESSAGE_DUPLICATE_PERSON); } - model.setPerson(personToEdit, editedPerson); + model.setPerson(patientToEdit, editedPatient); model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); - return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, editedPerson)); + return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, editedPatient)); } /** - * Creates and returns a {@code Person} with the details of {@code personToEdit} + * Creates and returns a {@code Patient} with the details of {@code patientToEdit} * edited with {@code editPersonDescriptor}. */ - private static Person createEditedPerson(Person personToEdit, EditPersonDescriptor editPersonDescriptor) { - assert personToEdit != null; + private static Patient createEditedPerson(Patient patientToEdit, EditPersonDescriptor editPersonDescriptor) { + assert patientToEdit != null; - Name updatedName = editPersonDescriptor.getName().orElse(personToEdit.getName()); - Phone updatedPhone = editPersonDescriptor.getPhone().orElse(personToEdit.getPhone()); - Email updatedEmail = editPersonDescriptor.getEmail().orElse(personToEdit.getEmail()); - Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress()); - Set updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); + Name updatedName = editPersonDescriptor.getName().orElse(patientToEdit.getName()); + Phone updatedPhone = editPersonDescriptor.getPhone().orElse(patientToEdit.getPhone()); + Email updatedEmail = editPersonDescriptor.getEmail().orElse(patientToEdit.getEmail()); + Address updatedAddress = editPersonDescriptor.getAddress().orElse(patientToEdit.getAddress()); + Set updatedTags = editPersonDescriptor.getTags().orElse(patientToEdit.getTags()); - return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedTags); + return new Patient(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedTags); } @Override @@ -121,8 +121,8 @@ public boolean equals(Object other) { } /** - * Stores the details to edit the person with. Each non-empty field value will replace the - * corresponding field value of the person. + * Stores the details to edit the patient with. Each non-empty field value will replace the + * corresponding field value of the patient. */ public static class EditPersonDescriptor { private Name name; diff --git a/src/main/java/seedu/address/logic/commands/FindCommand.java b/src/main/java/seedu/address/logic/commands/FindCommand.java index d6b19b0a0de..9c55eaccad7 100644 --- a/src/main/java/seedu/address/logic/commands/FindCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindCommand.java @@ -4,7 +4,7 @@ import seedu.address.commons.core.Messages; import seedu.address.model.Model; -import seedu.address.model.person.NameContainsKeywordsPredicate; +import seedu.address.model.patient.NameContainsKeywordsPredicate; /** * Finds and lists all persons in address book whose name contains any of the argument keywords. diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index 3b8bfa035e8..d00670abf4f 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -12,11 +12,11 @@ import seedu.address.logic.commands.AddCommand; import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Person; -import seedu.address.model.person.Phone; +import seedu.address.model.patient.Address; +import seedu.address.model.patient.Email; +import seedu.address.model.patient.Name; +import seedu.address.model.patient.Patient; +import seedu.address.model.patient.Phone; import seedu.address.model.tag.Tag; /** @@ -44,9 +44,9 @@ public AddCommand parse(String args) throws ParseException { Address address = ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get()); Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG)); - Person person = new Person(name, phone, email, address, tagList); + Patient patient = new Patient(name, phone, email, address, tagList); - return new AddCommand(person); + return new AddCommand(patient); } /** diff --git a/src/main/java/seedu/address/logic/parser/FindCommandParser.java b/src/main/java/seedu/address/logic/parser/FindCommandParser.java index 4fb71f23103..16997011d8b 100644 --- a/src/main/java/seedu/address/logic/parser/FindCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/FindCommandParser.java @@ -6,7 +6,7 @@ import seedu.address.logic.commands.FindCommand; import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.person.NameContainsKeywordsPredicate; +import seedu.address.model.patient.NameContainsKeywordsPredicate; /** * Parses input arguments and creates a new FindCommand object diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index b117acb9c55..d4b34666a2e 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -9,10 +9,10 @@ import seedu.address.commons.core.index.Index; import seedu.address.commons.util.StringUtil; import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Phone; +import seedu.address.model.patient.Address; +import seedu.address.model.patient.Email; +import seedu.address.model.patient.Name; +import seedu.address.model.patient.Phone; import seedu.address.model.tag.Tag; /** diff --git a/src/main/java/seedu/address/model/AddressBook.java b/src/main/java/seedu/address/model/AddressBook.java index 1a943a0781a..5e726ff69a7 100644 --- a/src/main/java/seedu/address/model/AddressBook.java +++ b/src/main/java/seedu/address/model/AddressBook.java @@ -5,8 +5,8 @@ import java.util.List; import javafx.collections.ObservableList; -import seedu.address.model.person.Person; -import seedu.address.model.person.UniquePersonList; +import seedu.address.model.patient.Patient; +import seedu.address.model.patient.UniquePersonList; /** * Wraps all data at the address-book level @@ -40,11 +40,11 @@ public AddressBook(ReadOnlyAddressBook toBeCopied) { //// list overwrite operations /** - * Replaces the contents of the person list with {@code persons}. - * {@code persons} must not contain duplicate persons. + * Replaces the contents of the patient list with {@code patients}. + * {@code patients} must not contain duplicate patients. */ - public void setPersons(List persons) { - this.persons.setPersons(persons); + public void setPersons(List patients) { + this.persons.setPersons(patients); } /** @@ -56,40 +56,40 @@ public void resetData(ReadOnlyAddressBook newData) { setPersons(newData.getPersonList()); } - //// person-level operations + //// patient-level operations /** - * Returns true if a person with the same identity as {@code person} exists in the address book. + * Returns true if a patient with the same identity as {@code patient} exists in the address book. */ - public boolean hasPerson(Person person) { - requireNonNull(person); - return persons.contains(person); + public boolean hasPerson(Patient patient) { + requireNonNull(patient); + return persons.contains(patient); } /** - * Adds a person to the address book. - * The person must not already exist in the address book. + * Adds a patient to the address book. + * The patient must not already exist in the address book. */ - public void addPerson(Person p) { + public void addPerson(Patient p) { persons.add(p); } /** - * Replaces the given person {@code target} in the list with {@code editedPerson}. + * Replaces the given patient {@code target} in the list with {@code editedPatient}. * {@code target} must exist in the address book. - * The person identity of {@code editedPerson} must not be the same as another existing person in the address book. + * The patient identity of {@code editedPatient} must not be the same as another existing patient in the address book. */ - public void setPerson(Person target, Person editedPerson) { - requireNonNull(editedPerson); + public void setPerson(Patient target, Patient editedPatient) { + requireNonNull(editedPatient); - persons.setPerson(target, editedPerson); + persons.setPerson(target, editedPatient); } /** * Removes {@code key} from this {@code AddressBook}. * {@code key} must exist in the address book. */ - public void removePerson(Person key) { + public void removePerson(Patient key) { persons.remove(key); } @@ -102,7 +102,7 @@ public String toString() { } @Override - public ObservableList getPersonList() { + public ObservableList getPersonList() { return persons.asUnmodifiableObservableList(); } diff --git a/src/main/java/seedu/address/model/Model.java b/src/main/java/seedu/address/model/Model.java index d54df471c1f..1388ef71892 100644 --- a/src/main/java/seedu/address/model/Model.java +++ b/src/main/java/seedu/address/model/Model.java @@ -5,14 +5,14 @@ import javafx.collections.ObservableList; import seedu.address.commons.core.GuiSettings; -import seedu.address.model.person.Person; +import seedu.address.model.patient.Patient; /** * The API of the Model component. */ public interface Model { /** {@code Predicate} that always evaluate to true */ - Predicate PREDICATE_SHOW_ALL_PERSONS = unused -> true; + Predicate PREDICATE_SHOW_ALL_PERSONS = unused -> true; /** * Replaces user prefs data with the data in {@code userPrefs}. @@ -53,35 +53,35 @@ public interface Model { ReadOnlyAddressBook getAddressBook(); /** - * Returns true if a person with the same identity as {@code person} exists in the address book. + * Returns true if a patient with the same identity as {@code patient} exists in the address book. */ - boolean hasPerson(Person person); + boolean hasPerson(Patient patient); /** - * Deletes the given person. - * The person must exist in the address book. + * Deletes the given patient. + * The patient must exist in the address book. */ - void deletePerson(Person target); + void deletePerson(Patient target); /** - * Adds the given person. - * {@code person} must not already exist in the address book. + * Adds the given patient. + * {@code patient} must not already exist in the address book. */ - void addPerson(Person person); + void addPerson(Patient patient); /** - * Replaces the given person {@code target} with {@code editedPerson}. + * Replaces the given patient {@code target} with {@code editedPatient}. * {@code target} must exist in the address book. - * The person identity of {@code editedPerson} must not be the same as another existing person in the address book. + * The patient identity of {@code editedPatient} must not be the same as another existing patient in the address book. */ - void setPerson(Person target, Person editedPerson); + void setPerson(Patient target, Patient editedPatient); - /** Returns an unmodifiable view of the filtered person list */ - ObservableList getFilteredPersonList(); + /** Returns an unmodifiable view of the filtered patient list */ + ObservableList getFilteredPersonList(); /** - * Updates the filter of the filtered person list to filter by the given {@code predicate}. + * Updates the filter of the filtered patient list to filter by the given {@code predicate}. * @throws NullPointerException if {@code predicate} is null. */ - void updateFilteredPersonList(Predicate predicate); + void updateFilteredPersonList(Predicate predicate); } diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java index 86c1df298d7..3f4ee63716c 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -11,7 +11,7 @@ import javafx.collections.transformation.FilteredList; import seedu.address.commons.core.GuiSettings; import seedu.address.commons.core.LogsCenter; -import seedu.address.model.person.Person; +import seedu.address.model.patient.Patient; /** * Represents the in-memory model of the address book data. @@ -21,7 +21,7 @@ public class ModelManager implements Model { private final AddressBook addressBook; private final UserPrefs userPrefs; - private final FilteredList filteredPersons; + private final FilteredList filteredPatients; /** * Initializes a ModelManager with the given addressBook and userPrefs. @@ -33,7 +33,7 @@ public ModelManager(ReadOnlyAddressBook addressBook, ReadOnlyUserPrefs userPrefs this.addressBook = new AddressBook(addressBook); this.userPrefs = new UserPrefs(userPrefs); - filteredPersons = new FilteredList<>(this.addressBook.getPersonList()); + filteredPatients = new FilteredList<>(this.addressBook.getPersonList()); } public ModelManager() { @@ -88,44 +88,44 @@ public ReadOnlyAddressBook getAddressBook() { } @Override - public boolean hasPerson(Person person) { - requireNonNull(person); - return addressBook.hasPerson(person); + public boolean hasPerson(Patient patient) { + requireNonNull(patient); + return addressBook.hasPerson(patient); } @Override - public void deletePerson(Person target) { + public void deletePerson(Patient target) { addressBook.removePerson(target); } @Override - public void addPerson(Person person) { - addressBook.addPerson(person); + public void addPerson(Patient patient) { + addressBook.addPerson(patient); updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); } @Override - public void setPerson(Person target, Person editedPerson) { - requireAllNonNull(target, editedPerson); + public void setPerson(Patient target, Patient editedPatient) { + requireAllNonNull(target, editedPatient); - addressBook.setPerson(target, editedPerson); + addressBook.setPerson(target, editedPatient); } - //=========== Filtered Person List Accessors ============================================================= + //=========== Filtered Patient List Accessors ============================================================= /** - * Returns an unmodifiable view of the list of {@code Person} backed by the internal list of + * Returns an unmodifiable view of the list of {@code Patient} backed by the internal list of * {@code versionedAddressBook} */ @Override - public ObservableList getFilteredPersonList() { - return filteredPersons; + public ObservableList getFilteredPersonList() { + return filteredPatients; } @Override - public void updateFilteredPersonList(Predicate predicate) { + public void updateFilteredPersonList(Predicate predicate) { requireNonNull(predicate); - filteredPersons.setPredicate(predicate); + filteredPatients.setPredicate(predicate); } @Override @@ -144,7 +144,7 @@ public boolean equals(Object obj) { ModelManager other = (ModelManager) obj; return addressBook.equals(other.addressBook) && userPrefs.equals(other.userPrefs) - && filteredPersons.equals(other.filteredPersons); + && filteredPatients.equals(other.filteredPatients); } } diff --git a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java b/src/main/java/seedu/address/model/ReadOnlyAddressBook.java index 6ddc2cd9a29..82aa5c16ec8 100644 --- a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java +++ b/src/main/java/seedu/address/model/ReadOnlyAddressBook.java @@ -1,7 +1,7 @@ package seedu.address.model; import javafx.collections.ObservableList; -import seedu.address.model.person.Person; +import seedu.address.model.patient.Patient; /** * Unmodifiable view of an address book @@ -12,6 +12,6 @@ public interface ReadOnlyAddressBook { * Returns an unmodifiable view of the persons list. * This list will not contain any duplicate persons. */ - ObservableList getPersonList(); + ObservableList getPersonList(); } diff --git a/src/main/java/seedu/address/model/person/Address.java b/src/main/java/seedu/address/model/patient/Address.java similarity index 94% rename from src/main/java/seedu/address/model/person/Address.java rename to src/main/java/seedu/address/model/patient/Address.java index 60472ca22a0..519fc9ff2d6 100644 --- a/src/main/java/seedu/address/model/person/Address.java +++ b/src/main/java/seedu/address/model/patient/Address.java @@ -1,10 +1,10 @@ -package seedu.address.model.person; +package seedu.address.model.patient; import static java.util.Objects.requireNonNull; import static seedu.address.commons.util.AppUtil.checkArgument; /** - * Represents a Person's address in the address book. + * Represents a Patient's address in the address book. * Guarantees: immutable; is valid as declared in {@link #isValidAddress(String)} */ public class Address { diff --git a/src/main/java/seedu/address/model/person/Email.java b/src/main/java/seedu/address/model/patient/Email.java similarity index 96% rename from src/main/java/seedu/address/model/person/Email.java rename to src/main/java/seedu/address/model/patient/Email.java index f866e7133de..bf0d26fea3b 100644 --- a/src/main/java/seedu/address/model/person/Email.java +++ b/src/main/java/seedu/address/model/patient/Email.java @@ -1,10 +1,10 @@ -package seedu.address.model.person; +package seedu.address.model.patient; import static java.util.Objects.requireNonNull; import static seedu.address.commons.util.AppUtil.checkArgument; /** - * Represents a Person's email in the address book. + * Represents a Patient's email in the address book. * Guarantees: immutable; is valid as declared in {@link #isValidEmail(String)} */ public class Email { diff --git a/src/main/java/seedu/address/model/person/Name.java b/src/main/java/seedu/address/model/patient/Name.java similarity index 94% rename from src/main/java/seedu/address/model/person/Name.java rename to src/main/java/seedu/address/model/patient/Name.java index 79244d71cf7..370d4bce479 100644 --- a/src/main/java/seedu/address/model/person/Name.java +++ b/src/main/java/seedu/address/model/patient/Name.java @@ -1,10 +1,10 @@ -package seedu.address.model.person; +package seedu.address.model.patient; import static java.util.Objects.requireNonNull; import static seedu.address.commons.util.AppUtil.checkArgument; /** - * Represents a Person's name in the address book. + * Represents a Patient's name in the address book. * Guarantees: immutable; is valid as declared in {@link #isValidName(String)} */ public class Name { diff --git a/src/main/java/seedu/address/model/person/NameContainsKeywordsPredicate.java b/src/main/java/seedu/address/model/patient/NameContainsKeywordsPredicate.java similarity index 77% rename from src/main/java/seedu/address/model/person/NameContainsKeywordsPredicate.java rename to src/main/java/seedu/address/model/patient/NameContainsKeywordsPredicate.java index c9b5868427c..c68777ac1db 100644 --- a/src/main/java/seedu/address/model/person/NameContainsKeywordsPredicate.java +++ b/src/main/java/seedu/address/model/patient/NameContainsKeywordsPredicate.java @@ -1,4 +1,4 @@ -package seedu.address.model.person; +package seedu.address.model.patient; import java.util.List; import java.util.function.Predicate; @@ -6,9 +6,9 @@ import seedu.address.commons.util.StringUtil; /** - * Tests that a {@code Person}'s {@code Name} matches any of the keywords given. + * Tests that a {@code Patient}'s {@code Name} matches any of the keywords given. */ -public class NameContainsKeywordsPredicate implements Predicate { +public class NameContainsKeywordsPredicate implements Predicate { private final List keywords; public NameContainsKeywordsPredicate(List keywords) { @@ -16,9 +16,9 @@ public NameContainsKeywordsPredicate(List keywords) { } @Override - public boolean test(Person person) { + public boolean test(Patient patient) { return keywords.stream() - .anyMatch(keyword -> StringUtil.containsWordIgnoreCase(person.getName().fullName, keyword)); + .anyMatch(keyword -> StringUtil.containsWordIgnoreCase(patient.getName().fullName, keyword)); } @Override diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/patient/Patient.java similarity index 76% rename from src/main/java/seedu/address/model/person/Person.java rename to src/main/java/seedu/address/model/patient/Patient.java index 8ff1d83fe89..27764160127 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/patient/Patient.java @@ -1,4 +1,4 @@ -package seedu.address.model.person; +package seedu.address.model.patient; import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; @@ -10,10 +10,10 @@ import seedu.address.model.tag.Tag; /** - * Represents a Person in the address book. + * Represents a Patient in the address book. * Guarantees: details are present and not null, field values are validated, immutable. */ -public class Person { +public class Patient { // Identity fields private final Name name; @@ -27,7 +27,7 @@ public class Person { /** * Every field must be present and not null. */ - public Person(Name name, Phone phone, Email email, Address address, Set tags) { + public Patient(Name name, Phone phone, Email email, Address address, Set tags) { requireAllNonNull(name, phone, email, address, tags); this.name = name; this.phone = phone; @@ -64,13 +64,13 @@ public Set getTags() { * Returns true if both persons have the same name. * This defines a weaker notion of equality between two persons. */ - public boolean isSamePerson(Person otherPerson) { - if (otherPerson == this) { + public boolean isSamePerson(Patient otherPatient) { + if (otherPatient == this) { return true; } - return otherPerson != null - && otherPerson.getName().equals(getName()); + return otherPatient != null + && otherPatient.getName().equals(getName()); } /** @@ -83,16 +83,16 @@ public boolean equals(Object other) { return true; } - if (!(other instanceof Person)) { + if (!(other instanceof Patient)) { return false; } - Person otherPerson = (Person) other; - return otherPerson.getName().equals(getName()) - && otherPerson.getPhone().equals(getPhone()) - && otherPerson.getEmail().equals(getEmail()) - && otherPerson.getAddress().equals(getAddress()) - && otherPerson.getTags().equals(getTags()); + Patient otherPatient = (Patient) other; + return otherPatient.getName().equals(getName()) + && otherPatient.getPhone().equals(getPhone()) + && otherPatient.getEmail().equals(getEmail()) + && otherPatient.getAddress().equals(getAddress()) + && otherPatient.getTags().equals(getTags()); } @Override diff --git a/src/main/java/seedu/address/model/person/Phone.java b/src/main/java/seedu/address/model/patient/Phone.java similarity index 93% rename from src/main/java/seedu/address/model/person/Phone.java rename to src/main/java/seedu/address/model/patient/Phone.java index 872c76b382f..f43433f90c1 100644 --- a/src/main/java/seedu/address/model/person/Phone.java +++ b/src/main/java/seedu/address/model/patient/Phone.java @@ -1,10 +1,10 @@ -package seedu.address.model.person; +package seedu.address.model.patient; import static java.util.Objects.requireNonNull; import static seedu.address.commons.util.AppUtil.checkArgument; /** - * Represents a Person's phone number in the address book. + * Represents a Patient's phone number in the address book. * Guarantees: immutable; is valid as declared in {@link #isValidPhone(String)} */ public class Phone { diff --git a/src/main/java/seedu/address/model/patient/UniquePersonList.java b/src/main/java/seedu/address/model/patient/UniquePersonList.java new file mode 100644 index 00000000000..6290dcfe8e7 --- /dev/null +++ b/src/main/java/seedu/address/model/patient/UniquePersonList.java @@ -0,0 +1,137 @@ +package seedu.address.model.patient; + +import static java.util.Objects.requireNonNull; +import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; + +import java.util.Iterator; +import java.util.List; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import seedu.address.model.patient.exceptions.DuplicatePersonException; +import seedu.address.model.patient.exceptions.PersonNotFoundException; + +/** + * A list of persons that enforces uniqueness between its elements and does not allow nulls. + * A patient is considered unique by comparing using {@code Patient#isSamePerson(Patient)}. As such, adding and updating of + * persons uses Patient#isSamePerson(Patient) for equality so as to ensure that the patient being added or updated is + * unique in terms of identity in the UniquePersonList. However, the removal of a patient uses Patient#equals(Object) so + * as to ensure that the patient with exactly the same fields will be removed. + * + * Supports a minimal set of list operations. + * + * @see Patient#isSamePerson(Patient) + */ +public class UniquePersonList implements Iterable { + + private final ObservableList internalList = FXCollections.observableArrayList(); + private final ObservableList internalUnmodifiableList = + FXCollections.unmodifiableObservableList(internalList); + + /** + * Returns true if the list contains an equivalent patient as the given argument. + */ + public boolean contains(Patient toCheck) { + requireNonNull(toCheck); + return internalList.stream().anyMatch(toCheck::isSamePerson); + } + + /** + * Adds a patient to the list. + * The patient must not already exist in the list. + */ + public void add(Patient toAdd) { + requireNonNull(toAdd); + if (contains(toAdd)) { + throw new DuplicatePersonException(); + } + internalList.add(toAdd); + } + + /** + * Replaces the patient {@code target} in the list with {@code editedPatient}. + * {@code target} must exist in the list. + * The patient identity of {@code editedPatient} must not be the same as another existing patient in the list. + */ + public void setPerson(Patient target, Patient editedPatient) { + requireAllNonNull(target, editedPatient); + + int index = internalList.indexOf(target); + if (index == -1) { + throw new PersonNotFoundException(); + } + + if (!target.isSamePerson(editedPatient) && contains(editedPatient)) { + throw new DuplicatePersonException(); + } + + internalList.set(index, editedPatient); + } + + /** + * Removes the equivalent patient from the list. + * The patient must exist in the list. + */ + public void remove(Patient toRemove) { + requireNonNull(toRemove); + if (!internalList.remove(toRemove)) { + throw new PersonNotFoundException(); + } + } + + public void setPersons(UniquePersonList replacement) { + requireNonNull(replacement); + internalList.setAll(replacement.internalList); + } + + /** + * Replaces the contents of this list with {@code patients}. + * {@code patients} must not contain duplicate patients. + */ + public void setPersons(List patients) { + requireAllNonNull(patients); + if (!personsAreUnique(patients)) { + throw new DuplicatePersonException(); + } + + internalList.setAll(patients); + } + + /** + * Returns the backing list as an unmodifiable {@code ObservableList}. + */ + public ObservableList asUnmodifiableObservableList() { + return internalUnmodifiableList; + } + + @Override + public Iterator iterator() { + return internalList.iterator(); + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof UniquePersonList // instanceof handles nulls + && internalList.equals(((UniquePersonList) other).internalList)); + } + + @Override + public int hashCode() { + return internalList.hashCode(); + } + + /** + * Returns true if {@code patients} contains only unique patients. + */ + private boolean personsAreUnique(List patients) { + for (int i = 0; i < patients.size() - 1; i++) { + for (int j = i + 1; j < patients.size(); j++) { + if (patients.get(i).isSamePerson(patients.get(j))) { + return false; + } + } + } + return true; + } +} diff --git a/src/main/java/seedu/address/model/person/exceptions/DuplicatePersonException.java b/src/main/java/seedu/address/model/patient/exceptions/DuplicatePersonException.java similarity index 86% rename from src/main/java/seedu/address/model/person/exceptions/DuplicatePersonException.java rename to src/main/java/seedu/address/model/patient/exceptions/DuplicatePersonException.java index d7290f59442..37bde4fc4f8 100644 --- a/src/main/java/seedu/address/model/person/exceptions/DuplicatePersonException.java +++ b/src/main/java/seedu/address/model/patient/exceptions/DuplicatePersonException.java @@ -1,4 +1,4 @@ -package seedu.address.model.person.exceptions; +package seedu.address.model.patient.exceptions; /** * Signals that the operation will result in duplicate Persons (Persons are considered duplicates if they have the same diff --git a/src/main/java/seedu/address/model/patient/exceptions/PersonNotFoundException.java b/src/main/java/seedu/address/model/patient/exceptions/PersonNotFoundException.java new file mode 100644 index 00000000000..a89125d9216 --- /dev/null +++ b/src/main/java/seedu/address/model/patient/exceptions/PersonNotFoundException.java @@ -0,0 +1,6 @@ +package seedu.address.model.patient.exceptions; + +/** + * Signals that the operation is unable to find the specified patient. + */ +public class PersonNotFoundException extends RuntimeException {} diff --git a/src/main/java/seedu/address/model/person/UniquePersonList.java b/src/main/java/seedu/address/model/person/UniquePersonList.java deleted file mode 100644 index 0fee4fe57e6..00000000000 --- a/src/main/java/seedu/address/model/person/UniquePersonList.java +++ /dev/null @@ -1,137 +0,0 @@ -package seedu.address.model.person; - -import static java.util.Objects.requireNonNull; -import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; - -import java.util.Iterator; -import java.util.List; - -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import seedu.address.model.person.exceptions.DuplicatePersonException; -import seedu.address.model.person.exceptions.PersonNotFoundException; - -/** - * A list of persons that enforces uniqueness between its elements and does not allow nulls. - * A person is considered unique by comparing using {@code Person#isSamePerson(Person)}. As such, adding and updating of - * persons uses Person#isSamePerson(Person) for equality so as to ensure that the person being added or updated is - * unique in terms of identity in the UniquePersonList. However, the removal of a person uses Person#equals(Object) so - * as to ensure that the person with exactly the same fields will be removed. - * - * Supports a minimal set of list operations. - * - * @see Person#isSamePerson(Person) - */ -public class UniquePersonList implements Iterable { - - private final ObservableList internalList = FXCollections.observableArrayList(); - private final ObservableList internalUnmodifiableList = - FXCollections.unmodifiableObservableList(internalList); - - /** - * Returns true if the list contains an equivalent person as the given argument. - */ - public boolean contains(Person toCheck) { - requireNonNull(toCheck); - return internalList.stream().anyMatch(toCheck::isSamePerson); - } - - /** - * Adds a person to the list. - * The person must not already exist in the list. - */ - public void add(Person toAdd) { - requireNonNull(toAdd); - if (contains(toAdd)) { - throw new DuplicatePersonException(); - } - internalList.add(toAdd); - } - - /** - * Replaces the person {@code target} in the list with {@code editedPerson}. - * {@code target} must exist in the list. - * The person identity of {@code editedPerson} must not be the same as another existing person in the list. - */ - public void setPerson(Person target, Person editedPerson) { - requireAllNonNull(target, editedPerson); - - int index = internalList.indexOf(target); - if (index == -1) { - throw new PersonNotFoundException(); - } - - if (!target.isSamePerson(editedPerson) && contains(editedPerson)) { - throw new DuplicatePersonException(); - } - - internalList.set(index, editedPerson); - } - - /** - * Removes the equivalent person from the list. - * The person must exist in the list. - */ - public void remove(Person toRemove) { - requireNonNull(toRemove); - if (!internalList.remove(toRemove)) { - throw new PersonNotFoundException(); - } - } - - public void setPersons(UniquePersonList replacement) { - requireNonNull(replacement); - internalList.setAll(replacement.internalList); - } - - /** - * Replaces the contents of this list with {@code persons}. - * {@code persons} must not contain duplicate persons. - */ - public void setPersons(List persons) { - requireAllNonNull(persons); - if (!personsAreUnique(persons)) { - throw new DuplicatePersonException(); - } - - internalList.setAll(persons); - } - - /** - * Returns the backing list as an unmodifiable {@code ObservableList}. - */ - public ObservableList asUnmodifiableObservableList() { - return internalUnmodifiableList; - } - - @Override - public Iterator iterator() { - return internalList.iterator(); - } - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof UniquePersonList // instanceof handles nulls - && internalList.equals(((UniquePersonList) other).internalList)); - } - - @Override - public int hashCode() { - return internalList.hashCode(); - } - - /** - * Returns true if {@code persons} contains only unique persons. - */ - private boolean personsAreUnique(List persons) { - for (int i = 0; i < persons.size() - 1; i++) { - for (int j = i + 1; j < persons.size(); j++) { - if (persons.get(i).isSamePerson(persons.get(j))) { - return false; - } - } - } - return true; - } -} diff --git a/src/main/java/seedu/address/model/person/exceptions/PersonNotFoundException.java b/src/main/java/seedu/address/model/person/exceptions/PersonNotFoundException.java deleted file mode 100644 index fa764426ca7..00000000000 --- a/src/main/java/seedu/address/model/person/exceptions/PersonNotFoundException.java +++ /dev/null @@ -1,6 +0,0 @@ -package seedu.address.model.person.exceptions; - -/** - * Signals that the operation is unable to find the specified person. - */ -public class PersonNotFoundException extends RuntimeException {} diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index 1806da4facf..6574db9221f 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -6,35 +6,32 @@ import seedu.address.model.AddressBook; import seedu.address.model.ReadOnlyAddressBook; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Person; -import seedu.address.model.person.Phone; +import seedu.address.model.patient.*; +import seedu.address.model.patient.Patient; import seedu.address.model.tag.Tag; /** * Contains utility methods for populating {@code AddressBook} with sample data. */ public class SampleDataUtil { - public static Person[] getSamplePersons() { - return new Person[] { - new Person(new Name("Alex Yeoh"), new Phone("87438807"), new Email("alexyeoh@example.com"), + public static Patient[] getSamplePersons() { + return new Patient[] { + new Patient(new Name("Alex Yeoh"), new Phone("87438807"), new Email("alexyeoh@example.com"), new Address("Blk 30 Geylang Street 29, #06-40"), getTagSet("friends")), - new Person(new Name("Bernice Yu"), new Phone("99272758"), new Email("berniceyu@example.com"), + new Patient(new Name("Bernice Yu"), new Phone("99272758"), new Email("berniceyu@example.com"), new Address("Blk 30 Lorong 3 Serangoon Gardens, #07-18"), getTagSet("colleagues", "friends")), - new Person(new Name("Charlotte Oliveiro"), new Phone("93210283"), new Email("charlotte@example.com"), + new Patient(new Name("Charlotte Oliveiro"), new Phone("93210283"), new Email("charlotte@example.com"), new Address("Blk 11 Ang Mo Kio Street 74, #11-04"), getTagSet("neighbours")), - new Person(new Name("David Li"), new Phone("91031282"), new Email("lidavid@example.com"), + new Patient(new Name("David Li"), new Phone("91031282"), new Email("lidavid@example.com"), new Address("Blk 436 Serangoon Gardens Street 26, #16-43"), getTagSet("family")), - new Person(new Name("Irfan Ibrahim"), new Phone("92492021"), new Email("irfan@example.com"), + new Patient(new Name("Irfan Ibrahim"), new Phone("92492021"), new Email("irfan@example.com"), new Address("Blk 47 Tampines Street 20, #17-35"), getTagSet("classmates")), - new Person(new Name("Roy Balakrishnan"), new Phone("92624417"), new Email("royb@example.com"), + new Patient(new Name("Roy Balakrishnan"), new Phone("92624417"), new Email("royb@example.com"), new Address("Blk 45 Aljunied Street 85, #11-31"), getTagSet("colleagues")) }; @@ -42,8 +39,8 @@ public static Person[] getSamplePersons() { public static ReadOnlyAddressBook getSampleAddressBook() { AddressBook sampleAb = new AddressBook(); - for (Person samplePerson : getSamplePersons()) { - sampleAb.addPerson(samplePerson); + for (Patient samplePatient : getSamplePersons()) { + sampleAb.addPerson(samplePatient); } return sampleAb; } diff --git a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java index a6321cec2ea..8f5df378b7c 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java @@ -10,19 +10,19 @@ import com.fasterxml.jackson.annotation.JsonProperty; import seedu.address.commons.exceptions.IllegalValueException; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Person; -import seedu.address.model.person.Phone; +import seedu.address.model.patient.Address; +import seedu.address.model.patient.Email; +import seedu.address.model.patient.Name; +import seedu.address.model.patient.Patient; +import seedu.address.model.patient.Phone; import seedu.address.model.tag.Tag; /** - * Jackson-friendly version of {@link Person}. + * Jackson-friendly version of {@link Patient}. */ class JsonAdaptedPerson { - public static final String MISSING_FIELD_MESSAGE_FORMAT = "Person's %s field is missing!"; + public static final String MISSING_FIELD_MESSAGE_FORMAT = "Patient's %s field is missing!"; private final String name; private final String phone; @@ -31,7 +31,7 @@ class JsonAdaptedPerson { private final List tagged = new ArrayList<>(); /** - * Constructs a {@code JsonAdaptedPerson} with the given person details. + * Constructs a {@code JsonAdaptedPerson} with the given patient details. */ @JsonCreator public JsonAdaptedPerson(@JsonProperty("name") String name, @JsonProperty("phone") String phone, @@ -47,9 +47,9 @@ public JsonAdaptedPerson(@JsonProperty("name") String name, @JsonProperty("phone } /** - * Converts a given {@code Person} into this class for Jackson use. + * Converts a given {@code Patient} into this class for Jackson use. */ - public JsonAdaptedPerson(Person source) { + public JsonAdaptedPerson(Patient source) { name = source.getName().fullName; phone = source.getPhone().value; email = source.getEmail().value; @@ -60,11 +60,11 @@ public JsonAdaptedPerson(Person source) { } /** - * Converts this Jackson-friendly adapted person object into the model's {@code Person} object. + * Converts this Jackson-friendly adapted patient object into the model's {@code Patient} object. * - * @throws IllegalValueException if there were any data constraints violated in the adapted person. + * @throws IllegalValueException if there were any data constraints violated in the adapted patient. */ - public Person toModelType() throws IllegalValueException { + public Patient toModelType() throws IllegalValueException { final List personTags = new ArrayList<>(); for (JsonAdaptedTag tag : tagged) { personTags.add(tag.toModelType()); @@ -103,7 +103,7 @@ public Person toModelType() throws IllegalValueException { final Address modelAddress = new Address(address); final Set modelTags = new HashSet<>(personTags); - return new Person(modelName, modelPhone, modelEmail, modelAddress, modelTags); + return new Patient(modelName, modelPhone, modelEmail, modelAddress, modelTags); } } diff --git a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java b/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java index 5efd834091d..1f8264f7216 100644 --- a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java +++ b/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java @@ -11,7 +11,7 @@ import seedu.address.commons.exceptions.IllegalValueException; import seedu.address.model.AddressBook; import seedu.address.model.ReadOnlyAddressBook; -import seedu.address.model.person.Person; +import seedu.address.model.patient.Patient; /** * An Immutable AddressBook that is serializable to JSON format. @@ -19,7 +19,7 @@ @JsonRootName(value = "addressbook") class JsonSerializableAddressBook { - public static final String MESSAGE_DUPLICATE_PERSON = "Persons list contains duplicate person(s)."; + public static final String MESSAGE_DUPLICATE_PERSON = "Persons list contains duplicate patient(s)."; private final List persons = new ArrayList<>(); @@ -48,11 +48,11 @@ public JsonSerializableAddressBook(ReadOnlyAddressBook source) { public AddressBook toModelType() throws IllegalValueException { AddressBook addressBook = new AddressBook(); for (JsonAdaptedPerson jsonAdaptedPerson : persons) { - Person person = jsonAdaptedPerson.toModelType(); - if (addressBook.hasPerson(person)) { + Patient patient = jsonAdaptedPerson.toModelType(); + if (addressBook.hasPerson(patient)) { throw new IllegalValueException(MESSAGE_DUPLICATE_PERSON); } - addressBook.addPerson(person); + addressBook.addPerson(patient); } return addressBook; } diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index 7fc927bc5d9..9f63348d580 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -7,10 +7,10 @@ import javafx.scene.layout.FlowPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Region; -import seedu.address.model.person.Person; +import seedu.address.model.patient.Patient; /** - * An UI component that displays information of a {@code Person}. + * An UI component that displays information of a {@code Patient}. */ public class PersonCard extends UiPart { @@ -24,7 +24,7 @@ public class PersonCard extends UiPart { * @see The issue on AddressBook level 4 */ - public final Person person; + public final Patient patient; @FXML private HBox cardPane; @@ -42,17 +42,17 @@ public class PersonCard extends UiPart { private FlowPane tags; /** - * Creates a {@code PersonCode} with the given {@code Person} and index to display. + * Creates a {@code PersonCode} with the given {@code Patient} and index to display. */ - public PersonCard(Person person, int displayedIndex) { + public PersonCard(Patient patient, int displayedIndex) { super(FXML); - this.person = person; + this.patient = patient; id.setText(displayedIndex + ". "); - name.setText(person.getName().fullName); - phone.setText(person.getPhone().value); - address.setText(person.getAddress().value); - email.setText(person.getEmail().value); - person.getTags().stream() + name.setText(patient.getName().fullName); + phone.setText(patient.getPhone().value); + address.setText(patient.getAddress().value); + email.setText(patient.getEmail().value); + patient.getTags().stream() .sorted(Comparator.comparing(tag -> tag.tagName)) .forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); } @@ -72,6 +72,6 @@ public boolean equals(Object other) { // state check PersonCard card = (PersonCard) other; return id.getText().equals(card.id.getText()) - && person.equals(card.person); + && patient.equals(card.patient); } } diff --git a/src/main/java/seedu/address/ui/PersonListPanel.java b/src/main/java/seedu/address/ui/PersonListPanel.java index f4c501a897b..68d6a2d8f49 100644 --- a/src/main/java/seedu/address/ui/PersonListPanel.java +++ b/src/main/java/seedu/address/ui/PersonListPanel.java @@ -8,7 +8,7 @@ import javafx.scene.control.ListView; import javafx.scene.layout.Region; import seedu.address.commons.core.LogsCenter; -import seedu.address.model.person.Person; +import seedu.address.model.patient.Patient; /** * Panel containing the list of persons. @@ -18,30 +18,30 @@ public class PersonListPanel extends UiPart { private final Logger logger = LogsCenter.getLogger(PersonListPanel.class); @FXML - private ListView personListView; + private ListView personListView; /** * Creates a {@code PersonListPanel} with the given {@code ObservableList}. */ - public PersonListPanel(ObservableList personList) { + public PersonListPanel(ObservableList patientList) { super(FXML); - personListView.setItems(personList); + personListView.setItems(patientList); personListView.setCellFactory(listView -> new PersonListViewCell()); } /** - * Custom {@code ListCell} that displays the graphics of a {@code Person} using a {@code PersonCard}. + * Custom {@code ListCell} that displays the graphics of a {@code Patient} using a {@code PersonCard}. */ - class PersonListViewCell extends ListCell { + class PersonListViewCell extends ListCell { @Override - protected void updateItem(Person person, boolean empty) { - super.updateItem(person, empty); + protected void updateItem(Patient patient, boolean empty) { + super.updateItem(patient, empty); - if (empty || person == null) { + if (empty || patient == null) { setGraphic(null); setText(null); } else { - setGraphic(new PersonCard(person, getIndex() + 1).getRoot()); + setGraphic(new PersonCard(patient, getIndex() + 1).getRoot()); } } } diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml index a431648f6c0..9bf0cb57de9 100644 --- a/src/main/resources/view/MainWindow.fxml +++ b/src/main/resources/view/MainWindow.fxml @@ -46,7 +46,7 @@ - + diff --git a/src/test/java/seedu/address/logic/LogicManagerTest.java b/src/test/java/seedu/address/logic/LogicManagerTest.java index ad923ac249a..0cbae2bea63 100644 --- a/src/test/java/seedu/address/logic/LogicManagerTest.java +++ b/src/test/java/seedu/address/logic/LogicManagerTest.java @@ -26,7 +26,7 @@ import seedu.address.model.ModelManager; import seedu.address.model.ReadOnlyAddressBook; import seedu.address.model.UserPrefs; -import seedu.address.model.person.Person; +import seedu.address.model.patient.Patient; import seedu.address.storage.JsonAddressBookStorage; import seedu.address.storage.JsonUserPrefsStorage; import seedu.address.storage.StorageManager; @@ -81,9 +81,9 @@ public void execute_storageThrowsIoException_throwsCommandException() { // Execute add command String addCommand = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY; - Person expectedPerson = new PersonBuilder(AMY).withTags().build(); + Patient expectedPatient = new PersonBuilder(AMY).withTags().build(); ModelManager expectedModel = new ModelManager(); - expectedModel.addPerson(expectedPerson); + expectedModel.addPerson(expectedPatient); String expectedMessage = LogicManager.FILE_OPS_ERROR_MESSAGE + DUMMY_IO_EXCEPTION; assertCommandFailure(addCommand, CommandException.class, expectedMessage, expectedModel); } diff --git a/src/test/java/seedu/address/logic/commands/AddCommandIntegrationTest.java b/src/test/java/seedu/address/logic/commands/AddCommandIntegrationTest.java index cb8714bb055..25da7c5f004 100644 --- a/src/test/java/seedu/address/logic/commands/AddCommandIntegrationTest.java +++ b/src/test/java/seedu/address/logic/commands/AddCommandIntegrationTest.java @@ -10,7 +10,7 @@ import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; -import seedu.address.model.person.Person; +import seedu.address.model.patient.Patient; import seedu.address.testutil.PersonBuilder; /** @@ -27,19 +27,19 @@ public void setUp() { @Test public void execute_newPerson_success() { - Person validPerson = new PersonBuilder().build(); + Patient validPatient = new PersonBuilder().build(); Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); - expectedModel.addPerson(validPerson); + expectedModel.addPerson(validPatient); - assertCommandSuccess(new AddCommand(validPerson), model, - String.format(AddCommand.MESSAGE_SUCCESS, validPerson), expectedModel); + assertCommandSuccess(new AddCommand(validPatient), model, + String.format(AddCommand.MESSAGE_SUCCESS, validPatient), expectedModel); } @Test public void execute_duplicatePerson_throwsCommandException() { - Person personInList = model.getAddressBook().getPersonList().get(0); - assertCommandFailure(new AddCommand(personInList), model, AddCommand.MESSAGE_DUPLICATE_PERSON); + Patient patientInList = model.getAddressBook().getPersonList().get(0); + assertCommandFailure(new AddCommand(patientInList), model, AddCommand.MESSAGE_DUPLICATE_PERSON); } } diff --git a/src/test/java/seedu/address/logic/commands/AddCommandTest.java b/src/test/java/seedu/address/logic/commands/AddCommandTest.java index 5865713d5dd..ed8ef9b0822 100644 --- a/src/test/java/seedu/address/logic/commands/AddCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/AddCommandTest.java @@ -20,7 +20,7 @@ import seedu.address.model.Model; import seedu.address.model.ReadOnlyAddressBook; import seedu.address.model.ReadOnlyUserPrefs; -import seedu.address.model.person.Person; +import seedu.address.model.patient.Patient; import seedu.address.testutil.PersonBuilder; public class AddCommandTest { @@ -33,27 +33,27 @@ public void constructor_nullPerson_throwsNullPointerException() { @Test public void execute_personAcceptedByModel_addSuccessful() throws Exception { ModelStubAcceptingPersonAdded modelStub = new ModelStubAcceptingPersonAdded(); - Person validPerson = new PersonBuilder().build(); + Patient validPatient = new PersonBuilder().build(); - CommandResult commandResult = new AddCommand(validPerson).execute(modelStub); + CommandResult commandResult = new AddCommand(validPatient).execute(modelStub); - assertEquals(String.format(AddCommand.MESSAGE_SUCCESS, validPerson), commandResult.getFeedbackToUser()); - assertEquals(Arrays.asList(validPerson), modelStub.personsAdded); + assertEquals(String.format(AddCommand.MESSAGE_SUCCESS, validPatient), commandResult.getFeedbackToUser()); + assertEquals(Arrays.asList(validPatient), modelStub.personsAdded); } @Test public void execute_duplicatePerson_throwsCommandException() { - Person validPerson = new PersonBuilder().build(); - AddCommand addCommand = new AddCommand(validPerson); - ModelStub modelStub = new ModelStubWithPerson(validPerson); + Patient validPatient = new PersonBuilder().build(); + AddCommand addCommand = new AddCommand(validPatient); + ModelStub modelStub = new ModelStubWithPerson(validPatient); assertThrows(CommandException.class, AddCommand.MESSAGE_DUPLICATE_PERSON, () -> addCommand.execute(modelStub)); } @Test public void equals() { - Person alice = new PersonBuilder().withName("Alice").build(); - Person bob = new PersonBuilder().withName("Bob").build(); + Patient alice = new PersonBuilder().withName("Alice").build(); + Patient bob = new PersonBuilder().withName("Bob").build(); AddCommand addAliceCommand = new AddCommand(alice); AddCommand addBobCommand = new AddCommand(bob); @@ -70,7 +70,7 @@ public void equals() { // null -> returns false assertFalse(addAliceCommand.equals(null)); - // different person -> returns false + // different patient -> returns false assertFalse(addAliceCommand.equals(addBobCommand)); } @@ -109,7 +109,7 @@ public void setAddressBookFilePath(Path addressBookFilePath) { } @Override - public void addPerson(Person person) { + public void addPerson(Patient patient) { throw new AssertionError("This method should not be called."); } @@ -124,65 +124,65 @@ public ReadOnlyAddressBook getAddressBook() { } @Override - public boolean hasPerson(Person person) { + public boolean hasPerson(Patient patient) { throw new AssertionError("This method should not be called."); } @Override - public void deletePerson(Person target) { + public void deletePerson(Patient target) { throw new AssertionError("This method should not be called."); } @Override - public void setPerson(Person target, Person editedPerson) { + public void setPerson(Patient target, Patient editedPatient) { throw new AssertionError("This method should not be called."); } @Override - public ObservableList getFilteredPersonList() { + public ObservableList getFilteredPersonList() { throw new AssertionError("This method should not be called."); } @Override - public void updateFilteredPersonList(Predicate predicate) { + public void updateFilteredPersonList(Predicate predicate) { throw new AssertionError("This method should not be called."); } } /** - * A Model stub that contains a single person. + * A Model stub that contains a single patient. */ private class ModelStubWithPerson extends ModelStub { - private final Person person; + private final Patient patient; - ModelStubWithPerson(Person person) { - requireNonNull(person); - this.person = person; + ModelStubWithPerson(Patient patient) { + requireNonNull(patient); + this.patient = patient; } @Override - public boolean hasPerson(Person person) { - requireNonNull(person); - return this.person.isSamePerson(person); + public boolean hasPerson(Patient patient) { + requireNonNull(patient); + return this.patient.isSamePerson(patient); } } /** - * A Model stub that always accept the person being added. + * A Model stub that always accept the patient being added. */ private class ModelStubAcceptingPersonAdded extends ModelStub { - final ArrayList personsAdded = new ArrayList<>(); + final ArrayList personsAdded = new ArrayList<>(); @Override - public boolean hasPerson(Person person) { - requireNonNull(person); - return personsAdded.stream().anyMatch(person::isSamePerson); + public boolean hasPerson(Patient patient) { + requireNonNull(patient); + return personsAdded.stream().anyMatch(patient::isSamePerson); } @Override - public void addPerson(Person person) { - requireNonNull(person); - personsAdded.add(person); + public void addPerson(Patient patient) { + requireNonNull(patient); + personsAdded.add(patient); } @Override diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 643a1d08069..00523d94252 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -17,8 +17,8 @@ import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.AddressBook; import seedu.address.model.Model; -import seedu.address.model.person.NameContainsKeywordsPredicate; -import seedu.address.model.person.Person; +import seedu.address.model.patient.NameContainsKeywordsPredicate; +import seedu.address.model.patient.Patient; import seedu.address.testutil.EditPersonDescriptorBuilder; /** @@ -99,27 +99,27 @@ public static void assertCommandSuccess(Command command, Model actualModel, Stri * Executes the given {@code command}, confirms that
* - a {@code CommandException} is thrown
* - the CommandException message matches {@code expectedMessage}
- * - the address book, filtered person list and selected person in {@code actualModel} remain unchanged + * - the address book, filtered patient list and selected patient in {@code actualModel} remain unchanged */ public static void assertCommandFailure(Command command, Model actualModel, String expectedMessage) { // we are unable to defensively copy the model for comparison later, so we can // only do so by copying its components. AddressBook expectedAddressBook = new AddressBook(actualModel.getAddressBook()); - List expectedFilteredList = new ArrayList<>(actualModel.getFilteredPersonList()); + List expectedFilteredList = new ArrayList<>(actualModel.getFilteredPersonList()); assertThrows(CommandException.class, expectedMessage, () -> command.execute(actualModel)); assertEquals(expectedAddressBook, actualModel.getAddressBook()); assertEquals(expectedFilteredList, actualModel.getFilteredPersonList()); } /** - * Updates {@code model}'s filtered list to show only the person at the given {@code targetIndex} in the + * Updates {@code model}'s filtered list to show only the patient at the given {@code targetIndex} in the * {@code model}'s address book. */ public static void showPersonAtIndex(Model model, Index targetIndex) { assertTrue(targetIndex.getZeroBased() < model.getFilteredPersonList().size()); - Person person = model.getFilteredPersonList().get(targetIndex.getZeroBased()); - final String[] splitName = person.getName().fullName.split("\\s+"); + Patient patient = model.getFilteredPersonList().get(targetIndex.getZeroBased()); + final String[] splitName = patient.getName().fullName.split("\\s+"); model.updateFilteredPersonList(new NameContainsKeywordsPredicate(Arrays.asList(splitName[0]))); assertEquals(1, model.getFilteredPersonList().size()); diff --git a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java index 45a8c910ba1..ca8fe774d5a 100644 --- a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java @@ -16,7 +16,7 @@ import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; -import seedu.address.model.person.Person; +import seedu.address.model.patient.Patient; /** * Contains integration tests (interaction with the Model) and unit tests for @@ -28,13 +28,13 @@ public class DeleteCommandTest { @Test public void execute_validIndexUnfilteredList_success() { - Person personToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + Patient patientToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); DeleteCommand deleteCommand = new DeleteCommand(INDEX_FIRST_PERSON); - String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, personToDelete); + String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, patientToDelete); ModelManager expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); - expectedModel.deletePerson(personToDelete); + expectedModel.deletePerson(patientToDelete); assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); } @@ -51,13 +51,13 @@ public void execute_invalidIndexUnfilteredList_throwsCommandException() { public void execute_validIndexFilteredList_success() { showPersonAtIndex(model, INDEX_FIRST_PERSON); - Person personToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + Patient patientToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); DeleteCommand deleteCommand = new DeleteCommand(INDEX_FIRST_PERSON); - String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, personToDelete); + String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, patientToDelete); Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); - expectedModel.deletePerson(personToDelete); + expectedModel.deletePerson(patientToDelete); showNoPerson(expectedModel); assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); @@ -94,7 +94,7 @@ public void equals() { // null -> returns false assertFalse(deleteFirstCommand.equals(null)); - // different person -> returns false + // different patient -> returns false assertFalse(deleteFirstCommand.equals(deleteSecondCommand)); } diff --git a/src/test/java/seedu/address/logic/commands/EditCommandTest.java b/src/test/java/seedu/address/logic/commands/EditCommandTest.java index 214c6c2507b..41a529eb883 100644 --- a/src/test/java/seedu/address/logic/commands/EditCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/EditCommandTest.java @@ -23,7 +23,7 @@ import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; -import seedu.address.model.person.Person; +import seedu.address.model.patient.Patient; import seedu.address.testutil.EditPersonDescriptorBuilder; import seedu.address.testutil.PersonBuilder; @@ -36,14 +36,14 @@ public class EditCommandTest { @Test public void execute_allFieldsSpecifiedUnfilteredList_success() { - Person editedPerson = new PersonBuilder().build(); - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(editedPerson).build(); + Patient editedPatient = new PersonBuilder().build(); + EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(editedPatient).build(); EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, descriptor); - String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, editedPerson); + String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, editedPatient); Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); - expectedModel.setPerson(model.getFilteredPersonList().get(0), editedPerson); + expectedModel.setPerson(model.getFilteredPersonList().get(0), editedPatient); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); } @@ -51,20 +51,20 @@ public void execute_allFieldsSpecifiedUnfilteredList_success() { @Test public void execute_someFieldsSpecifiedUnfilteredList_success() { Index indexLastPerson = Index.fromOneBased(model.getFilteredPersonList().size()); - Person lastPerson = model.getFilteredPersonList().get(indexLastPerson.getZeroBased()); + Patient lastPatient = model.getFilteredPersonList().get(indexLastPerson.getZeroBased()); - PersonBuilder personInList = new PersonBuilder(lastPerson); - Person editedPerson = personInList.withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) + PersonBuilder personInList = new PersonBuilder(lastPatient); + Patient editedPatient = personInList.withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) .withTags(VALID_TAG_HUSBAND).build(); EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB) .withPhone(VALID_PHONE_BOB).withTags(VALID_TAG_HUSBAND).build(); EditCommand editCommand = new EditCommand(indexLastPerson, descriptor); - String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, editedPerson); + String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, editedPatient); Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); - expectedModel.setPerson(lastPerson, editedPerson); + expectedModel.setPerson(lastPatient, editedPatient); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); } @@ -72,9 +72,9 @@ public void execute_someFieldsSpecifiedUnfilteredList_success() { @Test public void execute_noFieldSpecifiedUnfilteredList_success() { EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, new EditPersonDescriptor()); - Person editedPerson = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + Patient editedPatient = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); - String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, editedPerson); + String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, editedPatient); Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); @@ -85,23 +85,23 @@ public void execute_noFieldSpecifiedUnfilteredList_success() { public void execute_filteredList_success() { showPersonAtIndex(model, INDEX_FIRST_PERSON); - Person personInFilteredList = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); - Person editedPerson = new PersonBuilder(personInFilteredList).withName(VALID_NAME_BOB).build(); + Patient patientInFilteredList = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + Patient editedPatient = new PersonBuilder(patientInFilteredList).withName(VALID_NAME_BOB).build(); EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB).build()); - String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, editedPerson); + String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, editedPatient); Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); - expectedModel.setPerson(model.getFilteredPersonList().get(0), editedPerson); + expectedModel.setPerson(model.getFilteredPersonList().get(0), editedPatient); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); } @Test public void execute_duplicatePersonUnfilteredList_failure() { - Person firstPerson = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(firstPerson).build(); + Patient firstPatient = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(firstPatient).build(); EditCommand editCommand = new EditCommand(INDEX_SECOND_PERSON, descriptor); assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_PERSON); @@ -111,10 +111,10 @@ public void execute_duplicatePersonUnfilteredList_failure() { public void execute_duplicatePersonFilteredList_failure() { showPersonAtIndex(model, INDEX_FIRST_PERSON); - // edit person in filtered list into a duplicate in address book - Person personInList = model.getAddressBook().getPersonList().get(INDEX_SECOND_PERSON.getZeroBased()); + // edit patient in filtered list into a duplicate in address book + Patient patientInList = model.getAddressBook().getPersonList().get(INDEX_SECOND_PERSON.getZeroBased()); EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, - new EditPersonDescriptorBuilder(personInList).build()); + new EditPersonDescriptorBuilder(patientInList).build()); assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_PERSON); } diff --git a/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java b/src/test/java/seedu/address/logic/commands/EditPatientDescriptorTest.java similarity index 98% rename from src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java rename to src/test/java/seedu/address/logic/commands/EditPatientDescriptorTest.java index e0288792e72..a42cfb2028b 100644 --- a/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java +++ b/src/test/java/seedu/address/logic/commands/EditPatientDescriptorTest.java @@ -15,7 +15,7 @@ import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; import seedu.address.testutil.EditPersonDescriptorBuilder; -public class EditPersonDescriptorTest { +public class EditPatientDescriptorTest { @Test public void equals() { diff --git a/src/test/java/seedu/address/logic/commands/FindCommandTest.java b/src/test/java/seedu/address/logic/commands/FindCommandTest.java index 9b15db28bbb..683486a287d 100644 --- a/src/test/java/seedu/address/logic/commands/FindCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindCommandTest.java @@ -18,7 +18,7 @@ import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; -import seedu.address.model.person.NameContainsKeywordsPredicate; +import seedu.address.model.patient.NameContainsKeywordsPredicate; /** * Contains integration tests (interaction with the Model) for {@code FindCommand}. @@ -50,7 +50,7 @@ public void equals() { // null -> returns false assertFalse(findFirstCommand.equals(null)); - // different person -> returns false + // different patient -> returns false assertFalse(findFirstCommand.equals(findSecondCommand)); } diff --git a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java index 5cf487d7ebb..421bfde1817 100644 --- a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java @@ -32,11 +32,8 @@ import org.junit.jupiter.api.Test; import seedu.address.logic.commands.AddCommand; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Person; -import seedu.address.model.person.Phone; +import seedu.address.model.patient.*; +import seedu.address.model.patient.Patient; import seedu.address.model.tag.Tag; import seedu.address.testutil.PersonBuilder; @@ -45,41 +42,41 @@ public class AddCommandParserTest { @Test public void parse_allFieldsPresent_success() { - Person expectedPerson = new PersonBuilder(BOB).withTags(VALID_TAG_FRIEND).build(); + Patient expectedPatient = new PersonBuilder(BOB).withTags(VALID_TAG_FRIEND).build(); // whitespace only preamble assertParseSuccess(parser, PREAMBLE_WHITESPACE + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB - + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); + + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPatient)); // multiple names - last name accepted assertParseSuccess(parser, NAME_DESC_AMY + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB - + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); + + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPatient)); // multiple phones - last phone accepted assertParseSuccess(parser, NAME_DESC_BOB + PHONE_DESC_AMY + PHONE_DESC_BOB + EMAIL_DESC_BOB - + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); + + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPatient)); // multiple emails - last email accepted assertParseSuccess(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_AMY + EMAIL_DESC_BOB - + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); + + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPatient)); // multiple addresses - last address accepted assertParseSuccess(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_AMY - + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); + + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPatient)); // multiple tags - all accepted - Person expectedPersonMultipleTags = new PersonBuilder(BOB).withTags(VALID_TAG_FRIEND, VALID_TAG_HUSBAND) + Patient expectedPatientMultipleTags = new PersonBuilder(BOB).withTags(VALID_TAG_FRIEND, VALID_TAG_HUSBAND) .build(); assertParseSuccess(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB - + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, new AddCommand(expectedPersonMultipleTags)); + + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, new AddCommand(expectedPatientMultipleTags)); } @Test public void parse_optionalFieldsMissing_success() { // zero tags - Person expectedPerson = new PersonBuilder(AMY).withTags().build(); + Patient expectedPatient = new PersonBuilder(AMY).withTags().build(); assertParseSuccess(parser, NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY, - new AddCommand(expectedPerson)); + new AddCommand(expectedPatient)); } @Test diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java index d9659205b57..6f6531bdd77 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java @@ -23,8 +23,8 @@ import seedu.address.logic.commands.HelpCommand; import seedu.address.logic.commands.ListCommand; import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.person.NameContainsKeywordsPredicate; -import seedu.address.model.person.Person; +import seedu.address.model.patient.NameContainsKeywordsPredicate; +import seedu.address.model.patient.Patient; import seedu.address.testutil.EditPersonDescriptorBuilder; import seedu.address.testutil.PersonBuilder; import seedu.address.testutil.PersonUtil; @@ -35,9 +35,9 @@ public class AddressBookParserTest { @Test public void parseCommand_add() throws Exception { - Person person = new PersonBuilder().build(); - AddCommand command = (AddCommand) parser.parseCommand(PersonUtil.getAddCommand(person)); - assertEquals(new AddCommand(person), command); + Patient patient = new PersonBuilder().build(); + AddCommand command = (AddCommand) parser.parseCommand(PersonUtil.getAddCommand(patient)); + assertEquals(new AddCommand(patient), command); } @Test @@ -55,8 +55,8 @@ public void parseCommand_delete() throws Exception { @Test public void parseCommand_edit() throws Exception { - Person person = new PersonBuilder().build(); - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(person).build(); + Patient patient = new PersonBuilder().build(); + EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(patient).build(); EditCommand command = (EditCommand) parser.parseCommand(EditCommand.COMMAND_WORD + " " + INDEX_FIRST_PERSON.getOneBased() + " " + PersonUtil.getEditPersonDescriptorDetails(descriptor)); assertEquals(new EditCommand(INDEX_FIRST_PERSON, descriptor), command); diff --git a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java index 2ff31522486..e7d340d3482 100644 --- a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java @@ -36,10 +36,10 @@ import seedu.address.commons.core.index.Index; import seedu.address.logic.commands.EditCommand; import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Phone; +import seedu.address.model.patient.Address; +import seedu.address.model.patient.Email; +import seedu.address.model.patient.Name; +import seedu.address.model.patient.Phone; import seedu.address.model.tag.Tag; import seedu.address.testutil.EditPersonDescriptorBuilder; @@ -94,7 +94,7 @@ public void parse_invalidValue_failure() { // is tested at {@code parse_invalidValueFollowedByValidValue_success()} assertParseFailure(parser, "1" + PHONE_DESC_BOB + INVALID_PHONE_DESC, Phone.MESSAGE_CONSTRAINTS); - // while parsing {@code PREFIX_TAG} alone will reset the tags of the {@code Person} being edited, + // while parsing {@code PREFIX_TAG} alone will reset the tags of the {@code Patient} being edited, // parsing it together with a valid tag results in error assertParseFailure(parser, "1" + TAG_DESC_FRIEND + TAG_DESC_HUSBAND + TAG_EMPTY, Tag.MESSAGE_CONSTRAINTS); assertParseFailure(parser, "1" + TAG_DESC_FRIEND + TAG_EMPTY + TAG_DESC_HUSBAND, Tag.MESSAGE_CONSTRAINTS); diff --git a/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java b/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java index 70f4f0e79c4..b43d981f461 100644 --- a/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test; import seedu.address.logic.commands.FindCommand; -import seedu.address.model.person.NameContainsKeywordsPredicate; +import seedu.address.model.patient.NameContainsKeywordsPredicate; public class FindCommandParserTest { diff --git a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java index 4256788b1a7..eeadb6808d2 100644 --- a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java +++ b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java @@ -14,10 +14,10 @@ import org.junit.jupiter.api.Test; import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Phone; +import seedu.address.model.patient.Address; +import seedu.address.model.patient.Email; +import seedu.address.model.patient.Name; +import seedu.address.model.patient.Phone; import seedu.address.model.tag.Tag; public class ParserUtilTest { diff --git a/src/test/java/seedu/address/model/AddressBookTest.java b/src/test/java/seedu/address/model/AddressBookTest.java index 87782528ecd..ef63193c96e 100644 --- a/src/test/java/seedu/address/model/AddressBookTest.java +++ b/src/test/java/seedu/address/model/AddressBookTest.java @@ -18,8 +18,8 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; -import seedu.address.model.person.Person; -import seedu.address.model.person.exceptions.DuplicatePersonException; +import seedu.address.model.patient.Patient; +import seedu.address.model.patient.exceptions.DuplicatePersonException; import seedu.address.testutil.PersonBuilder; public class AddressBookTest { @@ -45,11 +45,11 @@ public void resetData_withValidReadOnlyAddressBook_replacesData() { @Test public void resetData_withDuplicatePersons_throwsDuplicatePersonException() { - // Two persons with the same identity fields - Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) + // Two patients with the same identity fields + Patient editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) .build(); - List newPersons = Arrays.asList(ALICE, editedAlice); - AddressBookStub newData = new AddressBookStub(newPersons); + List newPatients = Arrays.asList(ALICE, editedAlice); + AddressBookStub newData = new AddressBookStub(newPatients); assertThrows(DuplicatePersonException.class, () -> addressBook.resetData(newData)); } @@ -73,7 +73,7 @@ public void hasPerson_personInAddressBook_returnsTrue() { @Test public void hasPerson_personWithSameIdentityFieldsInAddressBook_returnsTrue() { addressBook.addPerson(ALICE); - Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) + Patient editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) .build(); assertTrue(addressBook.hasPerson(editedAlice)); } @@ -84,18 +84,18 @@ public void getPersonList_modifyList_throwsUnsupportedOperationException() { } /** - * A stub ReadOnlyAddressBook whose persons list can violate interface constraints. + * A stub ReadOnlyAddressBook whose patients list can violate interface constraints. */ private static class AddressBookStub implements ReadOnlyAddressBook { - private final ObservableList persons = FXCollections.observableArrayList(); + private final ObservableList patients = FXCollections.observableArrayList(); - AddressBookStub(Collection persons) { - this.persons.setAll(persons); + AddressBookStub(Collection patients) { + this.patients.setAll(patients); } @Override - public ObservableList getPersonList() { - return persons; + public ObservableList getPersonList() { + return patients; } } diff --git a/src/test/java/seedu/address/model/ModelManagerTest.java b/src/test/java/seedu/address/model/ModelManagerTest.java index 2cf1418d116..37e632d8a82 100644 --- a/src/test/java/seedu/address/model/ModelManagerTest.java +++ b/src/test/java/seedu/address/model/ModelManagerTest.java @@ -15,7 +15,7 @@ import org.junit.jupiter.api.Test; import seedu.address.commons.core.GuiSettings; -import seedu.address.model.person.NameContainsKeywordsPredicate; +import seedu.address.model.patient.NameContainsKeywordsPredicate; import seedu.address.testutil.AddressBookBuilder; public class ModelManagerTest { diff --git a/src/test/java/seedu/address/model/person/AddressTest.java b/src/test/java/seedu/address/model/patient/AddressTest.java similarity index 97% rename from src/test/java/seedu/address/model/person/AddressTest.java rename to src/test/java/seedu/address/model/patient/AddressTest.java index dcd3be87b3a..7a0e236341e 100644 --- a/src/test/java/seedu/address/model/person/AddressTest.java +++ b/src/test/java/seedu/address/model/patient/AddressTest.java @@ -1,4 +1,4 @@ -package seedu.address.model.person; +package seedu.address.model.patient; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/src/test/java/seedu/address/model/person/EmailTest.java b/src/test/java/seedu/address/model/patient/EmailTest.java similarity index 99% rename from src/test/java/seedu/address/model/person/EmailTest.java rename to src/test/java/seedu/address/model/patient/EmailTest.java index bbcc6c8c98e..bc43abef24f 100644 --- a/src/test/java/seedu/address/model/person/EmailTest.java +++ b/src/test/java/seedu/address/model/patient/EmailTest.java @@ -1,4 +1,4 @@ -package seedu.address.model.person; +package seedu.address.model.patient; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/src/test/java/seedu/address/model/person/NameContainsKeywordsPredicateTest.java b/src/test/java/seedu/address/model/patient/NameContainsKeywordsPredicateTest.java similarity index 97% rename from src/test/java/seedu/address/model/person/NameContainsKeywordsPredicateTest.java rename to src/test/java/seedu/address/model/patient/NameContainsKeywordsPredicateTest.java index f136664e017..3b53bb294d0 100644 --- a/src/test/java/seedu/address/model/person/NameContainsKeywordsPredicateTest.java +++ b/src/test/java/seedu/address/model/patient/NameContainsKeywordsPredicateTest.java @@ -1,4 +1,4 @@ -package seedu.address.model.person; +package seedu.address.model.patient; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -34,7 +34,7 @@ public void equals() { // null -> returns false assertFalse(firstPredicate.equals(null)); - // different person -> returns false + // different patient -> returns false assertFalse(firstPredicate.equals(secondPredicate)); } diff --git a/src/test/java/seedu/address/model/person/NameTest.java b/src/test/java/seedu/address/model/patient/NameTest.java similarity index 97% rename from src/test/java/seedu/address/model/person/NameTest.java rename to src/test/java/seedu/address/model/patient/NameTest.java index c9801392874..896467807b9 100644 --- a/src/test/java/seedu/address/model/person/NameTest.java +++ b/src/test/java/seedu/address/model/patient/NameTest.java @@ -1,4 +1,4 @@ -package seedu.address.model.person; +package seedu.address.model.patient; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/src/test/java/seedu/address/model/person/PersonTest.java b/src/test/java/seedu/address/model/patient/PatientTest.java similarity index 85% rename from src/test/java/seedu/address/model/person/PersonTest.java rename to src/test/java/seedu/address/model/patient/PatientTest.java index b29c097cfd4..a27bcd0b81d 100644 --- a/src/test/java/seedu/address/model/person/PersonTest.java +++ b/src/test/java/seedu/address/model/patient/PatientTest.java @@ -1,4 +1,4 @@ -package seedu.address.model.person; +package seedu.address.model.patient; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -15,12 +15,12 @@ import seedu.address.testutil.PersonBuilder; -public class PersonTest { +public class PatientTest { @Test public void asObservableList_modifyList_throwsUnsupportedOperationException() { - Person person = new PersonBuilder().build(); - assertThrows(UnsupportedOperationException.class, () -> person.getTags().remove(0)); + Patient patient = new PersonBuilder().build(); + assertThrows(UnsupportedOperationException.class, () -> patient.getTags().remove(0)); } @Test @@ -32,7 +32,7 @@ public void isSamePerson() { assertFalse(ALICE.isSamePerson(null)); // same name, all other attributes different -> returns true - Person editedAlice = new PersonBuilder(ALICE).withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB) + Patient editedAlice = new PersonBuilder(ALICE).withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB) .withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND).build(); assertTrue(ALICE.isSamePerson(editedAlice)); @@ -41,7 +41,7 @@ public void isSamePerson() { assertFalse(ALICE.isSamePerson(editedAlice)); // name differs in case, all other attributes same -> returns false - Person editedBob = new PersonBuilder(BOB).withName(VALID_NAME_BOB.toLowerCase()).build(); + Patient editedBob = new PersonBuilder(BOB).withName(VALID_NAME_BOB.toLowerCase()).build(); assertFalse(BOB.isSamePerson(editedBob)); // name has trailing spaces, all other attributes same -> returns false @@ -53,7 +53,7 @@ public void isSamePerson() { @Test public void equals() { // same values -> returns true - Person aliceCopy = new PersonBuilder(ALICE).build(); + Patient aliceCopy = new PersonBuilder(ALICE).build(); assertTrue(ALICE.equals(aliceCopy)); // same object -> returns true @@ -65,11 +65,11 @@ public void equals() { // different type -> returns false assertFalse(ALICE.equals(5)); - // different person -> returns false + // different patient -> returns false assertFalse(ALICE.equals(BOB)); // different name -> returns false - Person editedAlice = new PersonBuilder(ALICE).withName(VALID_NAME_BOB).build(); + Patient editedAlice = new PersonBuilder(ALICE).withName(VALID_NAME_BOB).build(); assertFalse(ALICE.equals(editedAlice)); // different phone -> returns false diff --git a/src/test/java/seedu/address/model/person/PhoneTest.java b/src/test/java/seedu/address/model/patient/PhoneTest.java similarity index 97% rename from src/test/java/seedu/address/model/person/PhoneTest.java rename to src/test/java/seedu/address/model/patient/PhoneTest.java index 8dd52766a5f..d8a6446d6fa 100644 --- a/src/test/java/seedu/address/model/person/PhoneTest.java +++ b/src/test/java/seedu/address/model/patient/PhoneTest.java @@ -1,4 +1,4 @@ -package seedu.address.model.person; +package seedu.address.model.patient; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/src/test/java/seedu/address/model/person/UniquePersonListTest.java b/src/test/java/seedu/address/model/patient/UniquePatientListTest.java similarity index 88% rename from src/test/java/seedu/address/model/person/UniquePersonListTest.java rename to src/test/java/seedu/address/model/patient/UniquePatientListTest.java index 1cc5fe9e0fe..168cb090d22 100644 --- a/src/test/java/seedu/address/model/person/UniquePersonListTest.java +++ b/src/test/java/seedu/address/model/patient/UniquePatientListTest.java @@ -1,4 +1,4 @@ -package seedu.address.model.person; +package seedu.address.model.patient; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -15,11 +15,11 @@ import org.junit.jupiter.api.Test; -import seedu.address.model.person.exceptions.DuplicatePersonException; -import seedu.address.model.person.exceptions.PersonNotFoundException; +import seedu.address.model.patient.exceptions.DuplicatePersonException; +import seedu.address.model.patient.exceptions.PersonNotFoundException; import seedu.address.testutil.PersonBuilder; -public class UniquePersonListTest { +public class UniquePatientListTest { private final UniquePersonList uniquePersonList = new UniquePersonList(); @@ -42,7 +42,7 @@ public void contains_personInList_returnsTrue() { @Test public void contains_personWithSameIdentityFieldsInList_returnsTrue() { uniquePersonList.add(ALICE); - Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) + Patient editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) .build(); assertTrue(uniquePersonList.contains(editedAlice)); } @@ -85,7 +85,7 @@ public void setPerson_editedPersonIsSamePerson_success() { @Test public void setPerson_editedPersonHasSameIdentity_success() { uniquePersonList.add(ALICE); - Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) + Patient editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND) .build(); uniquePersonList.setPerson(ALICE, editedAlice); UniquePersonList expectedUniquePersonList = new UniquePersonList(); @@ -143,14 +143,14 @@ public void setPersons_uniquePersonList_replacesOwnListWithProvidedUniquePersonL @Test public void setPersons_nullList_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniquePersonList.setPersons((List) null)); + assertThrows(NullPointerException.class, () -> uniquePersonList.setPersons((List) null)); } @Test public void setPersons_list_replacesOwnListWithProvidedList() { uniquePersonList.add(ALICE); - List personList = Collections.singletonList(BOB); - uniquePersonList.setPersons(personList); + List patientList = Collections.singletonList(BOB); + uniquePersonList.setPersons(patientList); UniquePersonList expectedUniquePersonList = new UniquePersonList(); expectedUniquePersonList.add(BOB); assertEquals(expectedUniquePersonList, uniquePersonList); @@ -158,8 +158,8 @@ public void setPersons_list_replacesOwnListWithProvidedList() { @Test public void setPersons_listWithDuplicatePersons_throwsDuplicatePersonException() { - List listWithDuplicatePersons = Arrays.asList(ALICE, ALICE); - assertThrows(DuplicatePersonException.class, () -> uniquePersonList.setPersons(listWithDuplicatePersons)); + List listWithDuplicatePatients = Arrays.asList(ALICE, ALICE); + assertThrows(DuplicatePersonException.class, () -> uniquePersonList.setPersons(listWithDuplicatePatients)); } @Test diff --git a/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java b/src/test/java/seedu/address/storage/JsonAdaptedPatientTest.java similarity index 96% rename from src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java rename to src/test/java/seedu/address/storage/JsonAdaptedPatientTest.java index 83b11331cdb..3f96769f1fa 100644 --- a/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java +++ b/src/test/java/seedu/address/storage/JsonAdaptedPatientTest.java @@ -12,12 +12,12 @@ import org.junit.jupiter.api.Test; import seedu.address.commons.exceptions.IllegalValueException; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Phone; +import seedu.address.model.patient.Address; +import seedu.address.model.patient.Email; +import seedu.address.model.patient.Name; +import seedu.address.model.patient.Phone; -public class JsonAdaptedPersonTest { +public class JsonAdaptedPatientTest { private static final String INVALID_NAME = "R@chel"; private static final String INVALID_PHONE = "+651234"; private static final String INVALID_ADDRESS = " "; diff --git a/src/test/java/seedu/address/testutil/AddressBookBuilder.java b/src/test/java/seedu/address/testutil/AddressBookBuilder.java index d53799fd110..b437d73845b 100644 --- a/src/test/java/seedu/address/testutil/AddressBookBuilder.java +++ b/src/test/java/seedu/address/testutil/AddressBookBuilder.java @@ -1,7 +1,7 @@ package seedu.address.testutil; import seedu.address.model.AddressBook; -import seedu.address.model.person.Person; +import seedu.address.model.patient.Patient; /** * A utility class to help with building Addressbook objects. @@ -21,10 +21,10 @@ public AddressBookBuilder(AddressBook addressBook) { } /** - * Adds a new {@code Person} to the {@code AddressBook} that we are building. + * Adds a new {@code Patient} to the {@code AddressBook} that we are building. */ - public AddressBookBuilder withPerson(Person person) { - addressBook.addPerson(person); + public AddressBookBuilder withPerson(Patient patient) { + addressBook.addPerson(patient); return this; } diff --git a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java index 4584bd5044e..fae2e9ed511 100644 --- a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java +++ b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java @@ -5,11 +5,11 @@ import java.util.stream.Stream; import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Person; -import seedu.address.model.person.Phone; +import seedu.address.model.patient.Address; +import seedu.address.model.patient.Email; +import seedu.address.model.patient.Name; +import seedu.address.model.patient.Patient; +import seedu.address.model.patient.Phone; import seedu.address.model.tag.Tag; /** @@ -28,15 +28,15 @@ public EditPersonDescriptorBuilder(EditPersonDescriptor descriptor) { } /** - * Returns an {@code EditPersonDescriptor} with fields containing {@code person}'s details + * Returns an {@code EditPersonDescriptor} with fields containing {@code patient}'s details */ - public EditPersonDescriptorBuilder(Person person) { + public EditPersonDescriptorBuilder(Patient patient) { descriptor = new EditPersonDescriptor(); - descriptor.setName(person.getName()); - descriptor.setPhone(person.getPhone()); - descriptor.setEmail(person.getEmail()); - descriptor.setAddress(person.getAddress()); - descriptor.setTags(person.getTags()); + descriptor.setName(patient.getName()); + descriptor.setPhone(patient.getPhone()); + descriptor.setEmail(patient.getEmail()); + descriptor.setAddress(patient.getAddress()); + descriptor.setTags(patient.getTags()); } /** diff --git a/src/test/java/seedu/address/testutil/PersonBuilder.java b/src/test/java/seedu/address/testutil/PersonBuilder.java index 6be381d39ba..43788d2a939 100644 --- a/src/test/java/seedu/address/testutil/PersonBuilder.java +++ b/src/test/java/seedu/address/testutil/PersonBuilder.java @@ -3,16 +3,16 @@ import java.util.HashSet; import java.util.Set; -import seedu.address.model.person.Address; -import seedu.address.model.person.Email; -import seedu.address.model.person.Name; -import seedu.address.model.person.Person; -import seedu.address.model.person.Phone; +import seedu.address.model.patient.Address; +import seedu.address.model.patient.Email; +import seedu.address.model.patient.Name; +import seedu.address.model.patient.Patient; +import seedu.address.model.patient.Phone; import seedu.address.model.tag.Tag; import seedu.address.model.util.SampleDataUtil; /** - * A utility class to help with building Person objects. + * A utility class to help with building Patient objects. */ public class PersonBuilder { @@ -39,18 +39,18 @@ public PersonBuilder() { } /** - * Initializes the PersonBuilder with the data of {@code personToCopy}. + * Initializes the PersonBuilder with the data of {@code patientToCopy}. */ - public PersonBuilder(Person personToCopy) { - name = personToCopy.getName(); - phone = personToCopy.getPhone(); - email = personToCopy.getEmail(); - address = personToCopy.getAddress(); - tags = new HashSet<>(personToCopy.getTags()); + public PersonBuilder(Patient patientToCopy) { + name = patientToCopy.getName(); + phone = patientToCopy.getPhone(); + email = patientToCopy.getEmail(); + address = patientToCopy.getAddress(); + tags = new HashSet<>(patientToCopy.getTags()); } /** - * Sets the {@code Name} of the {@code Person} that we are building. + * Sets the {@code Name} of the {@code Patient} that we are building. */ public PersonBuilder withName(String name) { this.name = new Name(name); @@ -58,7 +58,7 @@ public PersonBuilder withName(String name) { } /** - * Parses the {@code tags} into a {@code Set} and set it to the {@code Person} that we are building. + * Parses the {@code tags} into a {@code Set} and set it to the {@code Patient} that we are building. */ public PersonBuilder withTags(String ... tags) { this.tags = SampleDataUtil.getTagSet(tags); @@ -66,7 +66,7 @@ public PersonBuilder withTags(String ... tags) { } /** - * Sets the {@code Address} of the {@code Person} that we are building. + * Sets the {@code Address} of the {@code Patient} that we are building. */ public PersonBuilder withAddress(String address) { this.address = new Address(address); @@ -74,7 +74,7 @@ public PersonBuilder withAddress(String address) { } /** - * Sets the {@code Phone} of the {@code Person} that we are building. + * Sets the {@code Phone} of the {@code Patient} that we are building. */ public PersonBuilder withPhone(String phone) { this.phone = new Phone(phone); @@ -82,15 +82,15 @@ public PersonBuilder withPhone(String phone) { } /** - * Sets the {@code Email} of the {@code Person} that we are building. + * Sets the {@code Email} of the {@code Patient} that we are building. */ public PersonBuilder withEmail(String email) { this.email = new Email(email); return this; } - public Person build() { - return new Person(name, phone, email, address, tags); + public Patient build() { + return new Patient(name, phone, email, address, tags); } } diff --git a/src/test/java/seedu/address/testutil/PersonUtil.java b/src/test/java/seedu/address/testutil/PersonUtil.java index 90849945183..aba0499be79 100644 --- a/src/test/java/seedu/address/testutil/PersonUtil.java +++ b/src/test/java/seedu/address/testutil/PersonUtil.java @@ -10,31 +10,31 @@ import seedu.address.logic.commands.AddCommand; import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; -import seedu.address.model.person.Person; +import seedu.address.model.patient.Patient; import seedu.address.model.tag.Tag; /** - * A utility class for Person. + * A utility class for Patient. */ public class PersonUtil { /** - * Returns an add command string for adding the {@code person}. + * Returns an add command string for adding the {@code patient}. */ - public static String getAddCommand(Person person) { - return AddCommand.COMMAND_WORD + " " + getPersonDetails(person); + public static String getAddCommand(Patient patient) { + return AddCommand.COMMAND_WORD + " " + getPersonDetails(patient); } /** - * Returns the part of command string for the given {@code person}'s details. + * Returns the part of command string for the given {@code patient}'s details. */ - public static String getPersonDetails(Person person) { + public static String getPersonDetails(Patient patient) { StringBuilder sb = new StringBuilder(); - sb.append(PREFIX_NAME + person.getName().fullName + " "); - sb.append(PREFIX_PHONE + person.getPhone().value + " "); - sb.append(PREFIX_EMAIL + person.getEmail().value + " "); - sb.append(PREFIX_ADDRESS + person.getAddress().value + " "); - person.getTags().stream().forEach( + sb.append(PREFIX_NAME + patient.getName().fullName + " "); + sb.append(PREFIX_PHONE + patient.getPhone().value + " "); + sb.append(PREFIX_EMAIL + patient.getEmail().value + " "); + sb.append(PREFIX_ADDRESS + patient.getAddress().value + " "); + patient.getTags().stream().forEach( s -> sb.append(PREFIX_TAG + s.tagName + " ") ); return sb.toString(); diff --git a/src/test/java/seedu/address/testutil/TestUtil.java b/src/test/java/seedu/address/testutil/TestUtil.java index 896d103eb0b..bff0f190ed6 100644 --- a/src/test/java/seedu/address/testutil/TestUtil.java +++ b/src/test/java/seedu/address/testutil/TestUtil.java @@ -7,7 +7,7 @@ import seedu.address.commons.core.index.Index; import seedu.address.model.Model; -import seedu.address.model.person.Person; +import seedu.address.model.patient.Patient; /** * A utility class for test cases. @@ -33,23 +33,23 @@ public static Path getFilePathInSandboxFolder(String fileName) { } /** - * Returns the middle index of the person in the {@code model}'s person list. + * Returns the middle index of the patient in the {@code model}'s patient list. */ public static Index getMidIndex(Model model) { return Index.fromOneBased(model.getFilteredPersonList().size() / 2); } /** - * Returns the last index of the person in the {@code model}'s person list. + * Returns the last index of the patient in the {@code model}'s patient list. */ public static Index getLastIndex(Model model) { return Index.fromOneBased(model.getFilteredPersonList().size()); } /** - * Returns the person in the {@code model}'s person list at {@code index}. + * Returns the patient in the {@code model}'s patient list at {@code index}. */ - public static Person getPerson(Model model, Index index) { + public static Patient getPerson(Model model, Index index) { return model.getFilteredPersonList().get(index.getZeroBased()); } } diff --git a/src/test/java/seedu/address/testutil/TypicalPersons.java b/src/test/java/seedu/address/testutil/TypicalPersons.java index fec76fb7129..56ecb665f81 100644 --- a/src/test/java/seedu/address/testutil/TypicalPersons.java +++ b/src/test/java/seedu/address/testutil/TypicalPersons.java @@ -16,42 +16,42 @@ import java.util.List; import seedu.address.model.AddressBook; -import seedu.address.model.person.Person; +import seedu.address.model.patient.Patient; /** - * A utility class containing a list of {@code Person} objects to be used in tests. + * A utility class containing a list of {@code Patient} objects to be used in tests. */ public class TypicalPersons { - public static final Person ALICE = new PersonBuilder().withName("Alice Pauline") + public static final Patient ALICE = new PersonBuilder().withName("Alice Pauline") .withAddress("123, Jurong West Ave 6, #08-111").withEmail("alice@example.com") .withPhone("94351253") .withTags("friends").build(); - public static final Person BENSON = new PersonBuilder().withName("Benson Meier") + public static final Patient BENSON = new PersonBuilder().withName("Benson Meier") .withAddress("311, Clementi Ave 2, #02-25") .withEmail("johnd@example.com").withPhone("98765432") .withTags("owesMoney", "friends").build(); - public static final Person CARL = new PersonBuilder().withName("Carl Kurz").withPhone("95352563") + public static final Patient CARL = new PersonBuilder().withName("Carl Kurz").withPhone("95352563") .withEmail("heinz@example.com").withAddress("wall street").build(); - public static final Person DANIEL = new PersonBuilder().withName("Daniel Meier").withPhone("87652533") + public static final Patient DANIEL = new PersonBuilder().withName("Daniel Meier").withPhone("87652533") .withEmail("cornelia@example.com").withAddress("10th street").withTags("friends").build(); - public static final Person ELLE = new PersonBuilder().withName("Elle Meyer").withPhone("9482224") + public static final Patient ELLE = new PersonBuilder().withName("Elle Meyer").withPhone("9482224") .withEmail("werner@example.com").withAddress("michegan ave").build(); - public static final Person FIONA = new PersonBuilder().withName("Fiona Kunz").withPhone("9482427") + public static final Patient FIONA = new PersonBuilder().withName("Fiona Kunz").withPhone("9482427") .withEmail("lydia@example.com").withAddress("little tokyo").build(); - public static final Person GEORGE = new PersonBuilder().withName("George Best").withPhone("9482442") + public static final Patient GEORGE = new PersonBuilder().withName("George Best").withPhone("9482442") .withEmail("anna@example.com").withAddress("4th street").build(); // Manually added - public static final Person HOON = new PersonBuilder().withName("Hoon Meier").withPhone("8482424") + public static final Patient HOON = new PersonBuilder().withName("Hoon Meier").withPhone("8482424") .withEmail("stefan@example.com").withAddress("little india").build(); - public static final Person IDA = new PersonBuilder().withName("Ida Mueller").withPhone("8482131") + public static final Patient IDA = new PersonBuilder().withName("Ida Mueller").withPhone("8482131") .withEmail("hans@example.com").withAddress("chicago ave").build(); - // Manually added - Person's details found in {@code CommandTestUtil} - public static final Person AMY = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) + // Manually added - Patient's details found in {@code CommandTestUtil} + public static final Patient AMY = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withTags(VALID_TAG_FRIEND).build(); - public static final Person BOB = new PersonBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) + public static final Patient BOB = new PersonBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND) .build(); @@ -64,13 +64,13 @@ private TypicalPersons() {} // prevents instantiation */ public static AddressBook getTypicalAddressBook() { AddressBook ab = new AddressBook(); - for (Person person : getTypicalPersons()) { - ab.addPerson(person); + for (Patient patient : getTypicalPersons()) { + ab.addPerson(patient); } return ab; } - public static List getTypicalPersons() { + public static List getTypicalPersons() { return new ArrayList<>(Arrays.asList(ALICE, BENSON, CARL, DANIEL, ELLE, FIONA, GEORGE)); } }