diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index 56c8d2dc39b..5318c195241 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -72,7 +72,7 @@ The **API** of this component is specified in [`Ui.java`](https://github.com/se- ![Structure of the UI Component](images/UiClassDiagram.png) -The UI consists of a `MainWindow` that is made up of parts e.g.`CommandBox`, `ResultDisplay`, `PersonListPanel`, `StatusBarFooter` etc. All these, including the `MainWindow`, inherit from the abstract `UiPart` class which captures the commonalities between classes that represent parts of the visible GUI. +The UI consists of a `MainWindow` that is made up of parts e.g.`CommandBox`, `ResultDisplay`, `StudentListPanel`, `StatusBarFooter` etc. All these, including the `MainWindow`, inherit from the abstract `UiPart` class which captures the commonalities between classes that represent parts of the visible GUI. The `UI` component uses the JavaFx UI framework. The layout of these UI parts are defined in matching `.fxml` files that are in the `src/main/resources/view` folder. For example, the layout of the [`MainWindow`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/ui/MainWindow.java) is specified in [`MainWindow.fxml`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/resources/view/MainWindow.fxml) @@ -81,7 +81,7 @@ The `UI` component, * executes user commands using the `Logic` component. * listens for changes to `Model` data so that the UI can be updated with the modified data. * keeps a reference to the `Logic` component, because the `UI` relies on the `Logic` to execute commands. -* depends on some classes in the `Model` component, as it displays `Person` object residing in the `Model`. +* depends on some classes in the `Model` component, as it displays `Student` object residing in the `Model`. ### Logic component @@ -102,7 +102,7 @@ How the `Logic` component works: 1. When `Logic` is called upon to execute a command, it is passed to an `AddressBookParser` object which in turn creates a parser that matches the command (e.g., `DeleteCommandParser`) and uses it to parse the command. 1. This results in a `Command` object (more precisely, an object of one of its subclasses e.g., `DeleteCommand`) which is executed by the `LogicManager`. -1. The command can communicate with the `Model` when it is executed (e.g. to delete a person).
+1. The command can communicate with the `Model` when it is executed (e.g. to delete a student).
Note that although this is shown as a single step in the diagram above (for simplicity), in the code it can take several interactions (between the command object and the `Model`) to achieve. 1. The result of the command execution is encapsulated as a `CommandResult` object which is returned back from `Logic`. @@ -122,12 +122,12 @@ How the parsing works: The `Model` component, -* stores the address book data i.e., all `Person` objects (which are contained in a `UniquePersonList` object). -* stores the currently 'selected' `Person` objects (e.g., results of a search query) as a separate _filtered_ list which is exposed to outsiders as an unmodifiable `ObservableList` that can be 'observed' e.g. the UI can be bound to this list so that the UI automatically updates when the data in the list change. +* stores the address book data i.e., all `Student` objects (which are contained in a `UniqueStudentList` object). +* stores the currently 'selected' `Student` objects (e.g., results of a search query) as a separate _filtered_ list which is exposed to outsiders as an unmodifiable `ObservableList` that can be 'observed' e.g. the UI can be bound to this list so that the UI automatically updates when the data in the list change. * stores a `UserPref` object that represents the user’s preferences. This is exposed to the outside as a `ReadOnlyUserPref` objects. * does not depend on any of the other three components (as the `Model` represents data entities of the domain, they should make sense on their own without depending on other components) -
:information_source: **Note:** An alternative (arguably, a more OOP) model is given below. It has a `Tag` list in the `AddressBook`, which `Person` references. This allows `AddressBook` to only require one `Tag` object per unique tag, instead of each `Person` needing their own `Tag` objects.
+
:information_source: **Note:** An alternative (arguably, a more OOP) model is given below. It has a `Tag` list in the `AddressBook`, which `Student` references. This allows `AddressBook` to only require one `Tag` object per unique tag, instead of each `Student` needing their own `Tag` objects.
@@ -173,11 +173,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 student 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 student. The `add` command also calls `Model#commitAddressBook()`, causing another modified address book state to be saved into the `addressBookStateList`. ![UndoRedoState2](images/UndoRedoState2.png) @@ -185,7 +185,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 student 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) @@ -234,7 +234,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 student being deleted). * Cons: We must ensure that the implementation of each individual command are correct. _{more aspects and alternatives to be added}_ @@ -399,7 +399,7 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli **MSS:** -1. User requests to delete a specific person in the list by index. +1. User requests to delete a specific student in the list by index. 2. TAHub verifies the given index. 3. TAHub deletes the student at the index in the list. 4. Use case ends. @@ -415,7 +415,7 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli ### Non-Functional Requirements 1. Should work on any _mainstream OS_ as long as it has Java `17` or above installed. -2. Should be able to hold up to 1000 persons without a noticeable sluggishness in performance for typical usage. +2. Should be able to hold up to 1000 students without a noticeable sluggishness in performance for typical usage. 3. A user with above average typing speed for regular English text (i.e. not code, not system admin commands) should be able to accomplish most of the tasks faster using commands than using the mouse. 4. The system should be able to scale to accommodate a growing number of users (teachers, TAs, students) without requiring significant reengineering. 5. The platform should have a clean, intuitive user interface that allows new users to complete basic tasks (like searching for a student) with minimal training. @@ -461,17 +461,17 @@ testers are expected to do more *exploratory* testing. 1. _{ more test cases …​ }_ -### Deleting a person +### Deleting a student -1. Deleting a person while all persons are being shown +1. Deleting a student while all students are being shown - 1. Prerequisites: List all persons using the `list` command. Multiple persons in the list. + 1. Prerequisites: List all students using the `list` command. Multiple students 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 student 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 4cc3bb472ee..a7ce5a1a2dc 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -72,46 +72,46 @@ Shows a message explaning how to access the help page. Format: `help` -### Adding a person: `add` +### Adding a student: `add` -Adds a person to the address book. +Adds a student to the address book. Format: `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS [t/TAG]…​`
:bulb: **Tip:** -A person can have any number of tags (including 0) +A student can have any number of tags (including 0)
Examples: * `add n/John Doe p/98765432 e/johnd@example.com a/John street, block 123, #01-01` * `add n/Betsy Crowe t/friend e/betsycrowe@example.com a/Newgate Prison p/1234567 t/criminal` -### Listing all persons : `list` +### Listing all students : `list` -Shows a list of all persons in the address book. +Shows a list of all students in the address book. Format: `list` -### Editing a person : `edit` +### Editing a student : `edit` -Edits an existing person in the address book. +Edits an existing student in the address book. Format: `edit INDEX [n/NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS] [t/TAG]…​` -* Edits the person at the specified `INDEX`. The index refers to the index number shown in the displayed person list. The index **must be a positive integer** 1, 2, 3, …​ +* Edits the student at the specified `INDEX`. The index refers to the index number shown in the displayed student list. The index **must be a positive integer** 1, 2, 3, …​ * At least one of the optional fields must be provided. * Existing values will be updated to the input values. -* When editing tags, the existing tags of the person will be removed i.e adding of tags is not cumulative. -* You can remove all the person’s tags by typing `t/` without +* When editing tags, the existing tags of the student will be removed i.e adding of tags is not cumulative. +* You can remove all the student’s tags by typing `t/` without specifying any tags after it. Examples: -* `edit 1 p/91234567 e/johndoe@example.com` Edits the phone number and email address of the 1st person to be `91234567` and `johndoe@example.com` respectively. -* `edit 2 n/Betsy Crower t/` Edits the name of the 2nd person to be `Betsy Crower` and clears all existing tags. +* `edit 1 p/91234567 e/johndoe@example.com` Edits the phone number and email address of the 1st student to be `91234567` and `johndoe@example.com` respectively. +* `edit 2 n/Betsy Crower t/` Edits the name of the 2nd student to be `Betsy Crower` and clears all existing tags. -### Locating persons by name: `find` +### Locating students by name: `find` -Finds persons whose names contain any of the given keywords. +Finds students whose names contain any of the given keywords. Format: `find KEYWORD [MORE_KEYWORDS]` @@ -119,7 +119,7 @@ Format: `find KEYWORD [MORE_KEYWORDS]` * The order of the keywords does not matter. e.g. `Hans Bo` will match `Bo Hans` * Only the name is searched. * Only full words will be matched e.g. `Han` will not match `Hans` -* Persons matching at least one keyword will be returned (i.e. `OR` search). +* Students matching at least one keyword will be returned (i.e. `OR` search). e.g. `Hans Bo` will return `Hans Gruber`, `Bo Yang` Examples: @@ -127,21 +127,21 @@ Examples: * `find alex david` returns `Alex Yeoh`, `David Li`
![result for 'find alex david'](images/findAlexDavidResult.png) -### Deleting a person : `delete` +### Deleting a student : `delete` -Deletes the specified person from the address book. +Deletes the specified student from the address book. Format: `delete i/INDEX...` -* Deletes the person at the specified `INDEX`. -* The index refers to the index number shown in the displayed person list. +* Deletes the student at the specified `INDEX`. +* The index refers to the index number shown in the displayed student list. * The index **must be a positive integer** 1, 2, 3, …​ * Can delete multiple items at once Examples: -* `list` followed by `delete i/2` deletes the 2nd person in the address book. -* `list` followed by `delete i/2 i/3` deletes the 2nd and 3rd person in the address book. -* `find Betsy` followed by `delete i/1` deletes the 1st person in the results of the `find` command. +* `list` followed by `delete i/2` deletes the 2nd student in the address book. +* `list` followed by `delete i/2 i/3` deletes the 2nd and 3rd student in the address book. +* `find Betsy` followed by `delete i/1` deletes the 1st student in the results of the `find` command. ### Clearing all entries : `clear` diff --git a/docs/diagrams/ArchitectureSequenceDiagram.puml b/docs/diagrams/ArchitectureSequenceDiagram.puml index 48b6cc4333c..1a887d8c1d4 100644 --- a/docs/diagrams/ArchitectureSequenceDiagram.puml +++ b/docs/diagrams/ArchitectureSequenceDiagram.puml @@ -14,7 +14,7 @@ activate ui UI_COLOR ui -[UI_COLOR]> logic : execute("delete 1") activate logic LOGIC_COLOR -logic -[LOGIC_COLOR]> model : deletePerson(p) +logic -[LOGIC_COLOR]> model : deleteStudent(p) activate model MODEL_COLOR model -[MODEL_COLOR]-> logic diff --git a/docs/diagrams/BetterModelClassDiagram.puml b/docs/diagrams/BetterModelClassDiagram.puml index 598474a5c82..7eac22ee974 100644 --- a/docs/diagrams/BetterModelClassDiagram.puml +++ b/docs/diagrams/BetterModelClassDiagram.puml @@ -4,18 +4,18 @@ skinparam arrowThickness 1.1 skinparam arrowColor MODEL_COLOR skinparam classBackgroundColor MODEL_COLOR -AddressBook *-right-> "1" UniquePersonList +AddressBook *-right-> "1" UniqueStudentList AddressBook *-right-> "1" UniqueTagList -UniqueTagList -[hidden]down- UniquePersonList -UniqueTagList -[hidden]down- UniquePersonList +UniqueTagList -[hidden]down- UniqueStudentList +UniqueTagList -[hidden]down- UniqueStudentList UniqueTagList -right-> "*" Tag -UniquePersonList -right-> Person +UniqueStudentList -right-> Student -Person -up-> "*" Tag +Student -up-> "*" Tag -Person *--> Name -Person *--> Phone -Person *--> Email -Person *--> Address +Student *--> Name +Student *--> Phone +Student *--> Email +Student *--> Address @enduml diff --git a/docs/diagrams/DeleteSequenceDiagram.puml b/docs/diagrams/DeleteSequenceDiagram.puml index 5241e79d7da..e7a1e82a9fd 100644 --- a/docs/diagrams/DeleteSequenceDiagram.puml +++ b/docs/diagrams/DeleteSequenceDiagram.puml @@ -49,7 +49,7 @@ deactivate AddressBookParser LogicManager -> DeleteCommand : execute(m) activate DeleteCommand -DeleteCommand -> Model : deletePerson(1) +DeleteCommand -> Model : deleteStudent(1) activate Model Model --> DeleteCommand diff --git a/docs/diagrams/ModelClassDiagram.puml b/docs/diagrams/ModelClassDiagram.puml index 0de5673070d..93b178963f8 100644 --- a/docs/diagrams/ModelClassDiagram.puml +++ b/docs/diagrams/ModelClassDiagram.puml @@ -12,8 +12,8 @@ Class AddressBook Class ModelManager Class UserPrefs -Class UniquePersonList -Class Person +Class UniqueStudentList +Class Student Class Address Class Email Class Name @@ -35,20 +35,20 @@ ModelManager -left-> "1" AddressBook ModelManager -right-> "1" UserPrefs UserPrefs .up.|> ReadOnlyUserPrefs -AddressBook *--> "1" UniquePersonList -UniquePersonList --> "~* all" Person -Person *--> Name -Person *--> Phone -Person *--> Email -Person *--> Address -Person *--> "*" Tag +AddressBook *--> "1" UniqueStudentList +UniqueStudentList --> "~* all" Student +Student *--> Name +Student *--> Phone +Student *--> Email +Student *--> Address +Student *--> "*" Tag -Person -[hidden]up--> I -UniquePersonList -[hidden]right-> I +Student -[hidden]up--> I +UniqueStudentList -[hidden]right-> I Name -[hidden]right-> Phone Phone -[hidden]right-> Address Address -[hidden]right-> Email -ModelManager --> "~* filtered" Person +ModelManager --> "~* filtered" Student @enduml diff --git a/docs/diagrams/StorageClassDiagram.puml b/docs/diagrams/StorageClassDiagram.puml index a821e06458c..0ceba1b2598 100644 --- a/docs/diagrams/StorageClassDiagram.puml +++ b/docs/diagrams/StorageClassDiagram.puml @@ -18,7 +18,7 @@ package "AddressBook Storage" #F4F6F6{ Class "<>\nAddressBookStorage" as AddressBookStorage Class JsonAddressBookStorage Class JsonSerializableAddressBook -Class JsonAdaptedPerson +Class JsonAdaptedStudent Class JsonAdaptedTag } @@ -37,7 +37,7 @@ Storage -right-|> AddressBookStorage JsonUserPrefsStorage .up.|> UserPrefsStorage JsonAddressBookStorage .up.|> AddressBookStorage JsonAddressBookStorage ..> JsonSerializableAddressBook -JsonSerializableAddressBook --> "*" JsonAdaptedPerson -JsonAdaptedPerson --> "*" JsonAdaptedTag +JsonSerializableAddressBook --> "*" JsonAdaptedStudent +JsonAdaptedStudent --> "*" JsonAdaptedTag @enduml diff --git a/docs/diagrams/UiClassDiagram.puml b/docs/diagrams/UiClassDiagram.puml index 95473d5aa19..927a6342276 100644 --- a/docs/diagrams/UiClassDiagram.puml +++ b/docs/diagrams/UiClassDiagram.puml @@ -11,8 +11,8 @@ Class UiManager Class MainWindow Class HelpWindow Class ResultDisplay -Class PersonListPanel -Class PersonCard +Class StudentListPanel +Class StudentCard Class StatusBarFooter Class CommandBox } @@ -32,26 +32,26 @@ UiManager .left.|> Ui UiManager -down-> "1" MainWindow MainWindow *-down-> "1" CommandBox MainWindow *-down-> "1" ResultDisplay -MainWindow *-down-> "1" PersonListPanel +MainWindow *-down-> "1" StudentListPanel MainWindow *-down-> "1" StatusBarFooter MainWindow --> "0..1" HelpWindow -PersonListPanel -down-> "*" PersonCard +StudentListPanel -down-> "*" StudentCard MainWindow -left-|> UiPart ResultDisplay --|> UiPart CommandBox --|> UiPart -PersonListPanel --|> UiPart -PersonCard --|> UiPart +StudentListPanel --|> UiPart +StudentCard --|> UiPart StatusBarFooter --|> UiPart HelpWindow --|> UiPart -PersonCard ..> Model +StudentCard ..> Model UiManager -right-> Logic MainWindow -left-> Logic -PersonListPanel -[hidden]left- HelpWindow +StudentListPanel -[hidden]left- HelpWindow HelpWindow -[hidden]left- CommandBox CommandBox -[hidden]left- ResultDisplay ResultDisplay -[hidden]left- StatusBarFooter diff --git a/docs/diagrams/tracing/LogicSequenceDiagram.puml b/docs/diagrams/tracing/LogicSequenceDiagram.puml index 42bf46d3ce8..acbf5532bc4 100644 --- a/docs/diagrams/tracing/LogicSequenceDiagram.puml +++ b/docs/diagrams/tracing/LogicSequenceDiagram.puml @@ -14,7 +14,7 @@ create ecp abp -> ecp abp -> ecp ++: parse(arguments) create ec -ecp -> ec ++: index, editPersonDescriptor +ecp -> ec ++: index, editStudentDescriptor ec --> ecp -- ecp --> abp --: command abp --> logic --: command diff --git a/src/main/java/seedu/address/logic/Logic.java b/src/main/java/seedu/address/logic/Logic.java index 641d315e68d..6696e55727a 100644 --- a/src/main/java/seedu/address/logic/Logic.java +++ b/src/main/java/seedu/address/logic/Logic.java @@ -30,8 +30,8 @@ public interface Logic { */ ReadOnlyAddressBook getAddressBook(); - /** Returns an unmodifiable view of the filtered list of persons */ - ObservableList getFilteredPersonList(); + /** Returns an unmodifiable view of the filtered list of students */ + ObservableList getFilteredStudentList(); /** * 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 e5ba9807bab..9f4986b9890 100644 --- a/src/main/java/seedu/address/logic/LogicManager.java +++ b/src/main/java/seedu/address/logic/LogicManager.java @@ -67,8 +67,8 @@ public ReadOnlyAddressBook getAddressBook() { } @Override - public ObservableList getFilteredPersonList() { - return model.getFilteredPersonList(); + public ObservableList getFilteredStudentList() { + return model.getFilteredStudentList(); } @Override diff --git a/src/main/java/seedu/address/logic/Messages.java b/src/main/java/seedu/address/logic/Messages.java index b7f22e87d10..7e69c04b2d6 100644 --- a/src/main/java/seedu/address/logic/Messages.java +++ b/src/main/java/seedu/address/logic/Messages.java @@ -14,10 +14,10 @@ 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 provided at index %1$d is invalid"; - - public static final String MESSAGE_INVALID_INDEX_SHOWN = "The person provided at index/indices %1$s is invalid"; - public static final String MESSAGE_PERSONS_LISTED_OVERVIEW = "%1$d persons listed!"; + public static final String MESSAGE_INVALID_STUDENT_DISPLAYED_INDEX = + "The student provided at index %1$d is invalid"; + public static final String MESSAGE_INVALID_INDEX_SHOWN = "The student provided at index/indices %1$s is invalid"; + public static final String MESSAGE_STUDENTS_LISTED_OVERVIEW = "%1$d students listed!"; public static final String MESSAGE_DUPLICATE_FIELDS = "Multiple values specified for the following single-valued field(s): "; @@ -34,17 +34,17 @@ public static String getErrorMessageForDuplicatePrefixes(Prefix... duplicatePref } /** - * Formats the {@code person} for display to the user. + * Formats the {@code student} for display to the user. */ - public static String format(Student person) { + public static String format(Student student) { final StringBuilder builder = new StringBuilder(); - builder.append(person.getName()) + builder.append(student.getName()) .append("; Phone: ") - .append(person.getPhone()) + .append(student.getPhone()) .append("; Email: ") - .append(person.getEmail()) + .append(student.getEmail()) .append("; Courses: "); - person.getCourses().forEach(builder::append); + student.getCourses().forEach(builder::append); return builder.toString(); } diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index feff0d09dc6..d0683c66db0 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -13,13 +13,13 @@ import seedu.address.model.student.Student; /** - * Adds a person to the address book. + * Adds a student 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 student to the address book. " + "Parameters: " + PREFIX_NAME + "NAME " + PREFIX_PHONE + "PHONE " @@ -30,28 +30,28 @@ public class AddCommand extends Command { + PREFIX_PHONE + "98765432 " + PREFIX_EMAIL + "johnd@example.com "; - 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 student added: %1$s"; + public static final String MESSAGE_DUPLICATE_STUDENT = "This student already exists in the address book"; private final Student toAdd; /** - * Creates an AddCommand to add the specified {@code Person} + * Creates an AddCommand to add the specified {@code Student} */ - public AddCommand(Student person) { - requireNonNull(person); - toAdd = person; + public AddCommand(Student student) { + requireNonNull(student); + toAdd = student; } @Override public CommandResult execute(Model model) throws CommandException { requireNonNull(model); - if (model.hasPerson(toAdd)) { - throw new CommandException(MESSAGE_DUPLICATE_PERSON); + if (model.hasStudent(toAdd)) { + throw new CommandException(MESSAGE_DUPLICATE_STUDENT); } - model.addPerson(toAdd); + model.addStudent(toAdd); return new CommandResult(String.format(MESSAGE_SUCCESS, Messages.format(toAdd))); } diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeleteCommand.java index 066982d9117..51332cefcfd 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java @@ -16,18 +16,18 @@ import seedu.address.model.student.Student; /** - * Deletes a person identified using it's displayed index from the address book. + * Deletes a student 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 student identified by the index number used in the displayed student list.\n" + "Parameters: " + PREFIX_DELETE_INDEX + "INDEX (must be a positive integer)...\n" + "Example: " + COMMAND_WORD + " " + PREFIX_DELETE_INDEX + "1"; - public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Deleted Person(s):\n%1$s"; + public static final String MESSAGE_DELETE_STUDENT_SUCCESS = "Deleted Student(s):\n%1$s"; private final Set targetIndices; @@ -38,7 +38,7 @@ public DeleteCommand(Set targetIndices) { @Override public CommandResult execute(Model model) throws CommandException { requireNonNull(model); - List lastShownList = model.getFilteredPersonList(); + List lastShownList = model.getFilteredStudentList(); boolean throwException = false; ArrayList outOfBounds = new ArrayList<>(); @@ -62,14 +62,14 @@ public CommandResult execute(Model model) throws CommandException { .toList(); - deletedPeople.forEach(model::deletePerson); + deletedPeople.forEach(model::deleteStudent); String formattedDeletedPeople = deletedPeople.stream() .map(Messages::format) .collect(Collectors.joining("\n")); - return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, formattedDeletedPeople)); + return new CommandResult(String.format(MESSAGE_DELETE_STUDENT_SUCCESS, formattedDeletedPeople)); } @Override diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index 1e6546b75c8..64852bf7e77 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -5,7 +5,7 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; -import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; +import static seedu.address.model.Model.PREDICATE_SHOW_ALL_STUDENTS; import java.util.Collections; import java.util.HashSet; @@ -46,52 +46,52 @@ public class EditCommand extends Command { + PREFIX_EMAIL + "johndoe@example.com " + PREFIX_COURSE + "CS2103T,CS2101"; - public static final String MESSAGE_EDIT_PERSON_SUCCESS = "Edited Student: %1$s"; + public static final String MESSAGE_EDIT_STUDENT_SUCCESS = "Edited Student: %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 student already exists in the address book."; + public static final String MESSAGE_DUPLICATE_STUDENT = "This student already exists in the address book."; private final Index index; - private final EditPersonDescriptor editStudentDescriptor; + private final EditStudentDescriptor editStudentDescriptor; /** * @param index of the student in the filtered student list to edit * @param editStudentDescriptor details to edit the student with */ - public EditCommand(Index index, EditPersonDescriptor editStudentDescriptor) { + public EditCommand(Index index, EditStudentDescriptor editStudentDescriptor) { requireNonNull(index); requireNonNull(editStudentDescriptor); this.index = index; - this.editStudentDescriptor = new EditPersonDescriptor(editStudentDescriptor); + this.editStudentDescriptor = new EditStudentDescriptor(editStudentDescriptor); } @Override public CommandResult execute(Model model) throws CommandException { requireNonNull(model); - List lastShownList = model.getFilteredPersonList(); + List lastShownList = model.getFilteredStudentList(); if (index.getZeroBased() >= lastShownList.size()) { - throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + throw new CommandException(Messages.MESSAGE_INVALID_STUDENT_DISPLAYED_INDEX); } Student studentToEdit = lastShownList.get(index.getZeroBased()); - Student editedStudent = createEditedPerson(studentToEdit, editStudentDescriptor); + Student editedStudent = createEditedStudent(studentToEdit, editStudentDescriptor); - if (!studentToEdit.isSamePerson(editedStudent) && model.hasPerson(editedStudent)) { - throw new CommandException(MESSAGE_DUPLICATE_PERSON); + if (!studentToEdit.isSameStudent(editedStudent) && model.hasStudent(editedStudent)) { + throw new CommandException(MESSAGE_DUPLICATE_STUDENT); } - model.setPerson(studentToEdit, editedStudent); - model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); - return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedStudent))); + model.setStudent(studentToEdit, editedStudent); + model.updateFilteredStudentList(PREDICATE_SHOW_ALL_STUDENTS); + return new CommandResult(String.format(MESSAGE_EDIT_STUDENT_SUCCESS, Messages.format(editedStudent))); } /** - * Creates and returns a {@code Person} with the details of {@code studentToEdit} - * edited with {@code editPersonDescriptor}. + * Creates and returns a {@code Student} with the details of {@code studentToEdit} + * edited with {@code editStudentDescriptor}. */ - private static Student createEditedPerson(Student studentToEdit, EditPersonDescriptor editStudentDescriptor) { + private static Student createEditedStudent(Student studentToEdit, EditStudentDescriptor editStudentDescriptor) { assert studentToEdit != null; Name updatedName = editStudentDescriptor.getName().orElse(studentToEdit.getName()); @@ -122,7 +122,7 @@ public boolean equals(Object other) { public String toString() { return new ToStringBuilder(this) .add("index", index) - .add("editPersonDescriptor", editStudentDescriptor) + .add("editStudentDescriptor", editStudentDescriptor) .toString(); } @@ -130,19 +130,19 @@ public String toString() { * Stores the details to edit the student with. Each non-empty field value will replace the * corresponding field value of the student. */ - public static class EditPersonDescriptor { + public static class EditStudentDescriptor { private Name name; private Phone phone; private Email email; private Set courses; - public EditPersonDescriptor() {} + public EditStudentDescriptor() {} /** * Copy constructor. * A defensive copy of {@code tags} is used internally. */ - public EditPersonDescriptor(EditPersonDescriptor toCopy) { + public EditStudentDescriptor(EditStudentDescriptor toCopy) { setName(toCopy.name); setPhone(toCopy.phone); setEmail(toCopy.email); @@ -204,11 +204,11 @@ public boolean equals(Object other) { } // instanceof handles nulls - if (!(other instanceof EditPersonDescriptor)) { + if (!(other instanceof EditStudentDescriptor)) { return false; } - EditPersonDescriptor otherEditStudentDescriptor = (EditPersonDescriptor) other; + EditStudentDescriptor otherEditStudentDescriptor = (EditStudentDescriptor) other; return Objects.equals(name, otherEditStudentDescriptor.name) && Objects.equals(phone, otherEditStudentDescriptor.phone) && Objects.equals(email, otherEditStudentDescriptor.email) diff --git a/src/main/java/seedu/address/logic/commands/FindCommand.java b/src/main/java/seedu/address/logic/commands/FindCommand.java index 4235b51ceb7..fff4941528d 100644 --- a/src/main/java/seedu/address/logic/commands/FindCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindCommand.java @@ -8,14 +8,14 @@ import seedu.address.model.student.NameContainsKeywordsPredicate; /** - * Finds and lists all persons in address book whose name contains any of the argument keywords. + * Finds and lists all students in address book whose name contains any of the argument keywords. * Keyword matching is case-insensitive. */ public class FindCommand extends Command { public static final String COMMAND_WORD = "find"; - public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all persons whose names contain any of " + public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all students whose names contain any of " + "the specified keywords (case-insensitive) and displays them as a list with index numbers.\n" + "Parameters: KEYWORD [MORE_KEYWORDS]...\n" + "Example: " + COMMAND_WORD + " alice bob charlie"; @@ -29,9 +29,9 @@ public FindCommand(NameContainsKeywordsPredicate predicate) { @Override public CommandResult execute(Model model) { requireNonNull(model); - model.updateFilteredPersonList(predicate); + model.updateFilteredStudentList(predicate); return new CommandResult( - String.format(Messages.MESSAGE_PERSONS_LISTED_OVERVIEW, model.getFilteredPersonList().size())); + String.format(Messages.MESSAGE_STUDENTS_LISTED_OVERVIEW, model.getFilteredStudentList().size())); } @Override diff --git a/src/main/java/seedu/address/logic/commands/ListCommand.java b/src/main/java/seedu/address/logic/commands/ListCommand.java index 84be6ad2596..77ab100be7c 100644 --- a/src/main/java/seedu/address/logic/commands/ListCommand.java +++ b/src/main/java/seedu/address/logic/commands/ListCommand.java @@ -1,24 +1,24 @@ package seedu.address.logic.commands; import static java.util.Objects.requireNonNull; -import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; +import static seedu.address.model.Model.PREDICATE_SHOW_ALL_STUDENTS; import seedu.address.model.Model; /** - * Lists all persons in the address book to the user. + * Lists all students in the address book to the user. */ public class ListCommand extends Command { public static final String COMMAND_WORD = "list"; - public static final String MESSAGE_SUCCESS = "Listed all persons"; + public static final String MESSAGE_SUCCESS = "Listed all students"; @Override public CommandResult execute(Model model) { requireNonNull(model); - model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); + model.updateFilteredStudentList(PREDICATE_SHOW_ALL_STUDENTS); return new CommandResult(MESSAGE_SUCCESS); } } diff --git a/src/main/java/seedu/address/logic/parser/EditCommandParser.java b/src/main/java/seedu/address/logic/parser/EditCommandParser.java index bf55d70d276..a966df3c5a1 100644 --- a/src/main/java/seedu/address/logic/parser/EditCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/EditCommandParser.java @@ -16,7 +16,7 @@ import seedu.address.commons.core.index.Index; import seedu.address.logic.commands.EditCommand; -import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; +import seedu.address.logic.commands.EditCommand.EditStudentDescriptor; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.course.Course; @@ -46,7 +46,7 @@ public EditCommand parse(String args) throws ParseException { argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL); - EditPersonDescriptor editStudentDescriptor = new EditPersonDescriptor(); + EditStudentDescriptor editStudentDescriptor = new EditStudentDescriptor(); if (argMultimap.getValue(PREFIX_NAME).isPresent()) { editStudentDescriptor.setName(ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get())); diff --git a/src/main/java/seedu/address/model/AddressBook.java b/src/main/java/seedu/address/model/AddressBook.java index b64e8956a33..631e187046e 100644 --- a/src/main/java/seedu/address/model/AddressBook.java +++ b/src/main/java/seedu/address/model/AddressBook.java @@ -7,15 +7,15 @@ import javafx.collections.ObservableList; import seedu.address.commons.util.ToStringBuilder; import seedu.address.model.student.Student; -import seedu.address.model.student.UniquePersonList; +import seedu.address.model.student.UniqueStudentList; /** * Wraps all data at the address-book level - * Duplicates are not allowed (by .isSamePerson comparison) + * Duplicates are not allowed (by .isSameStudent comparison) */ public class AddressBook implements ReadOnlyAddressBook { - private final UniquePersonList persons; + private final UniqueStudentList students; /* * The 'unusual' code block below is a non-static initialization block, sometimes used to avoid duplication @@ -25,13 +25,13 @@ public class AddressBook implements ReadOnlyAddressBook { * among constructors. */ { - persons = new UniquePersonList(); + students = new UniqueStudentList(); } public AddressBook() {} /** - * Creates an AddressBook using the Persons in the {@code toBeCopied} + * Creates an AddressBook using the Students in the {@code toBeCopied} */ public AddressBook(ReadOnlyAddressBook toBeCopied) { this(); @@ -41,11 +41,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 student list with {@code students}. + * {@code students} must not contain duplicate students. */ - public void setPersons(List persons) { - this.persons.setPersons(persons); + public void setStudents(List students) { + this.students.setStudents(students); } /** @@ -54,44 +54,45 @@ public void setPersons(List persons) { public void resetData(ReadOnlyAddressBook newData) { requireNonNull(newData); - setPersons(newData.getPersonList()); + setStudents(newData.getStudentList()); } - //// person-level operations + //// student-level operations /** - * Returns true if a person with the same identity as {@code person} exists in the address book. + * Returns true if a student with the same identity as {@code student} exists in the address book. */ - public boolean hasPerson(Student person) { - requireNonNull(person); - return persons.contains(person); + public boolean hasStudent(Student student) { + requireNonNull(student); + return students.contains(student); } /** - * Adds a person to the address book. - * The person must not already exist in the address book. + * Adds a student to the address book. + * The student must not already exist in the address book. */ - public void addPerson(Student p) { - persons.add(p); + public void addStudent(Student p) { + students.add(p); } /** - * Replaces the given person {@code target} in the list with {@code editedPerson}. + * Replaces the given student {@code target} in the list with {@code editedStudent}. * {@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 student identity of {@code editedStudent} must not be the same + * as another existing student in the address book. */ - public void setPerson(Student target, Student editedPerson) { - requireNonNull(editedPerson); + public void setStudent(Student target, Student editedStudent) { + requireNonNull(editedStudent); - persons.setPerson(target, editedPerson); + students.setStudent(target, editedStudent); } /** * Removes {@code key} from this {@code AddressBook}. * {@code key} must exist in the address book. */ - public void removePerson(Student key) { - persons.remove(key); + public void removeStudent(Student key) { + students.remove(key); } //// util methods @@ -99,13 +100,13 @@ public void removePerson(Student key) { @Override public String toString() { return new ToStringBuilder(this) - .add("persons", persons) + .add("students", students) .toString(); } @Override - public ObservableList getPersonList() { - return persons.asUnmodifiableObservableList(); + public ObservableList getStudentList() { + return students.asUnmodifiableObservableList(); } @Override @@ -120,11 +121,11 @@ public boolean equals(Object other) { } AddressBook otherAddressBook = (AddressBook) other; - return persons.equals(otherAddressBook.persons); + return students.equals(otherAddressBook.students); } @Override public int hashCode() { - return persons.hashCode(); + return students.hashCode(); } } diff --git a/src/main/java/seedu/address/model/Model.java b/src/main/java/seedu/address/model/Model.java index 0b16afe805b..6fe4b57ca12 100644 --- a/src/main/java/seedu/address/model/Model.java +++ b/src/main/java/seedu/address/model/Model.java @@ -12,7 +12,7 @@ */ public interface Model { /** {@code Predicate} that always evaluate to true */ - Predicate PREDICATE_SHOW_ALL_PERSONS = unused -> true; + Predicate PREDICATE_SHOW_ALL_STUDENTS = unused -> true; /** * Replaces user prefs data with the data in {@code userPrefs}. @@ -53,35 +53,36 @@ 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 student with the same identity as {@code student} exists in the address book. */ - boolean hasPerson(Student person); + boolean hasStudent(Student student); /** - * Deletes the given person. - * The person must exist in the address book. + * Deletes the given student. + * The student must exist in the address book. */ - void deletePerson(Student target); + void deleteStudent(Student target); /** - * Adds the given person. - * {@code person} must not already exist in the address book. + * Adds the given student. + * {@code student} must not already exist in the address book. */ - void addPerson(Student person); + void addStudent(Student student); /** - * Replaces the given person {@code target} with {@code editedPerson}. + * Replaces the given student {@code target} with {@code editedStudent}. * {@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 student identity of {@code editedStudent} must not be the same as + * another existing student in the address book. */ - void setPerson(Student target, Student editedPerson); + void setStudent(Student target, Student editedStudent); - /** Returns an unmodifiable view of the filtered person list */ - ObservableList getFilteredPersonList(); + /** Returns an unmodifiable view of the filtered student list */ + ObservableList getFilteredStudentList(); /** - * Updates the filter of the filtered person list to filter by the given {@code predicate}. + * Updates the filter of the filtered student list to filter by the given {@code predicate}. * @throws NullPointerException if {@code predicate} is null. */ - void updateFilteredPersonList(Predicate predicate); + void updateFilteredStudentList(Predicate predicate); } diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java index d4ecd58fe18..7c01e105432 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -21,7 +21,7 @@ public class ModelManager implements Model { private final AddressBook addressBook; private final UserPrefs userPrefs; - private final FilteredList filteredPersons; + private final FilteredList filteredStudents; /** * 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()); + filteredStudents = new FilteredList<>(this.addressBook.getStudentList()); } public ModelManager() { @@ -88,44 +88,44 @@ public ReadOnlyAddressBook getAddressBook() { } @Override - public boolean hasPerson(Student person) { - requireNonNull(person); - return addressBook.hasPerson(person); + public boolean hasStudent(Student student) { + requireNonNull(student); + return addressBook.hasStudent(student); } @Override - public void deletePerson(Student target) { - addressBook.removePerson(target); + public void deleteStudent(Student target) { + addressBook.removeStudent(target); } @Override - public void addPerson(Student person) { - addressBook.addPerson(person); - updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); + public void addStudent(Student student) { + addressBook.addStudent(student); + updateFilteredStudentList(PREDICATE_SHOW_ALL_STUDENTS); } @Override - public void setPerson(Student target, Student editedPerson) { - requireAllNonNull(target, editedPerson); + public void setStudent(Student target, Student editedStudent) { + requireAllNonNull(target, editedStudent); - addressBook.setPerson(target, editedPerson); + addressBook.setStudent(target, editedStudent); } - //=========== Filtered Person List Accessors ============================================================= + //=========== Filtered Student 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 Student} backed by the internal list of * {@code versionedAddressBook} */ @Override - public ObservableList getFilteredPersonList() { - return filteredPersons; + public ObservableList getFilteredStudentList() { + return filteredStudents; } @Override - public void updateFilteredPersonList(Predicate predicate) { + public void updateFilteredStudentList(Predicate predicate) { requireNonNull(predicate); - filteredPersons.setPredicate(predicate); + filteredStudents.setPredicate(predicate); } @Override @@ -142,7 +142,7 @@ public boolean equals(Object other) { ModelManager otherModelManager = (ModelManager) other; return addressBook.equals(otherModelManager.addressBook) && userPrefs.equals(otherModelManager.userPrefs) - && filteredPersons.equals(otherModelManager.filteredPersons); + && filteredStudents.equals(otherModelManager.filteredStudents); } } diff --git a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java b/src/main/java/seedu/address/model/ReadOnlyAddressBook.java index e1c7f661f4d..4fac98ec6b0 100644 --- a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java +++ b/src/main/java/seedu/address/model/ReadOnlyAddressBook.java @@ -9,9 +9,9 @@ public interface ReadOnlyAddressBook { /** - * Returns an unmodifiable view of the persons list. - * This list will not contain any duplicate persons. + * Returns an unmodifiable view of the students list. + * This list will not contain any duplicate students. */ - ObservableList getPersonList(); + ObservableList getStudentList(); } diff --git a/src/main/java/seedu/address/model/student/Email.java b/src/main/java/seedu/address/model/student/Email.java index 69c18fc7933..88e4f1a4fa7 100644 --- a/src/main/java/seedu/address/model/student/Email.java +++ b/src/main/java/seedu/address/model/student/Email.java @@ -4,7 +4,7 @@ import static seedu.address.commons.util.AppUtil.checkArgument; /** - * Represents a Person's email in the address book. + * Represents a Student'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/student/Name.java b/src/main/java/seedu/address/model/student/Name.java index 3622c3cc2da..7379cdca9a2 100644 --- a/src/main/java/seedu/address/model/student/Name.java +++ b/src/main/java/seedu/address/model/student/Name.java @@ -4,7 +4,7 @@ import static seedu.address.commons.util.AppUtil.checkArgument; /** - * Represents a Person's name in the address book. + * Represents a Student'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/student/NameContainsKeywordsPredicate.java b/src/main/java/seedu/address/model/student/NameContainsKeywordsPredicate.java index b673dcec508..cd97267de2d 100644 --- a/src/main/java/seedu/address/model/student/NameContainsKeywordsPredicate.java +++ b/src/main/java/seedu/address/model/student/NameContainsKeywordsPredicate.java @@ -7,7 +7,7 @@ import seedu.address.commons.util.ToStringBuilder; /** - * Tests that a {@code Person}'s {@code Name} matches any of the keywords given. + * Tests that a {@code Student}'s {@code Name} matches any of the keywords given. */ public class NameContainsKeywordsPredicate implements Predicate { private final List keywords; @@ -17,9 +17,9 @@ public NameContainsKeywordsPredicate(List keywords) { } @Override - public boolean test(Student person) { + public boolean test(Student student) { return keywords.stream() - .anyMatch(keyword -> StringUtil.containsWordIgnoreCase(person.getName().fullName, keyword)); + .anyMatch(keyword -> StringUtil.containsWordIgnoreCase(student.getName().fullName, keyword)); } @Override diff --git a/src/main/java/seedu/address/model/student/Phone.java b/src/main/java/seedu/address/model/student/Phone.java index e4058bf85c0..7692ab40d8a 100644 --- a/src/main/java/seedu/address/model/student/Phone.java +++ b/src/main/java/seedu/address/model/student/Phone.java @@ -4,7 +4,7 @@ import static seedu.address.commons.util.AppUtil.checkArgument; /** - * Represents a Person's phone number in the address book. + * Represents a Student'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/student/Student.java b/src/main/java/seedu/address/model/student/Student.java index d759e62181c..a53f39ff931 100644 --- a/src/main/java/seedu/address/model/student/Student.java +++ b/src/main/java/seedu/address/model/student/Student.java @@ -11,7 +11,7 @@ import seedu.address.model.course.Course; /** - * Represents a Person in the address book. + * Represents a Student in the address book. * Guarantees: details are present and not null, field values are validated, immutable. */ public class Student { @@ -56,21 +56,21 @@ public Set getCourses() { } /** - * Returns true if both persons have the same name. - * This defines a weaker notion of equality between two persons. + * Returns true if both students have the same name. + * This defines a weaker notion of equality between two students. */ - public boolean isSamePerson(Student otherPerson) { - if (otherPerson == this) { + public boolean isSameStudent(Student otherStudent) { + if (otherStudent == this) { return true; } - return otherPerson != null - && otherPerson.getName().equals(getName()); + return otherStudent != null + && otherStudent.getName().equals(getName()); } /** - * Returns true if both persons have the same identity and data fields. - * This defines a stronger notion of equality between two persons. + * Returns true if both students have the same identity and data fields. + * This defines a stronger notion of equality between two students. */ @Override public boolean equals(Object other) { @@ -83,11 +83,11 @@ public boolean equals(Object other) { return false; } - Student otherPerson = (Student) other; - return name.equals(otherPerson.name) - && phone.equals(otherPerson.phone) - && email.equals(otherPerson.email) - && courses.equals(otherPerson.courses); + Student otherStudent = (Student) other; + return name.equals(otherStudent.name) + && phone.equals(otherStudent.phone) + && email.equals(otherStudent.email) + && courses.equals(otherStudent.courses); } @Override diff --git a/src/main/java/seedu/address/model/student/UniquePersonList.java b/src/main/java/seedu/address/model/student/UniquePersonList.java deleted file mode 100644 index e861a954f00..00000000000 --- a/src/main/java/seedu/address/model/student/UniquePersonList.java +++ /dev/null @@ -1,150 +0,0 @@ -package seedu.address.model.student; - -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.student.exceptions.DuplicatePersonException; -import seedu.address.model.student.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 Student#isSamePerson(Student) - */ -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(Student 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(Student 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(Student target, Student 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(Student 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) { - if (other == this) { - return true; - } - - // instanceof handles nulls - if (!(other instanceof UniquePersonList)) { - return false; - } - - UniquePersonList otherUniquePersonList = (UniquePersonList) other; - return internalList.equals(otherUniquePersonList.internalList); - } - - @Override - public int hashCode() { - return internalList.hashCode(); - } - - @Override - public String toString() { - return internalList.toString(); - } - - /** - * 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/student/UniqueStudentList.java b/src/main/java/seedu/address/model/student/UniqueStudentList.java new file mode 100644 index 00000000000..95e6706a6ae --- /dev/null +++ b/src/main/java/seedu/address/model/student/UniqueStudentList.java @@ -0,0 +1,151 @@ +package seedu.address.model.student; + +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.student.exceptions.DuplicateStudentException; +import seedu.address.model.student.exceptions.StudentNotFoundException; + +/** + * A list of students that enforces uniqueness between its elements and does not allow nulls. + * A student is considered unique by comparing using {@code Student#isSameStudent(Student)}. + * As such, adding and updating of students uses Student#isSameStudent(Student) for equality + * so as to ensure that the student being added or updated is unique in terms of identity in + * the UniqueStudentList. However, the removal of a student uses Student#equals(Object) + * so as to ensure that the student with exactly the same fields will be removed. + * + * Supports a minimal set of list operations. + * + * @see Student#isSameStudent(Student) + */ +public class UniqueStudentList implements Iterable { + + private final ObservableList internalList = FXCollections.observableArrayList(); + private final ObservableList internalUnmodifiableList = + FXCollections.unmodifiableObservableList(internalList); + + /** + * Returns true if the list contains an equivalent student as the given argument. + */ + public boolean contains(Student toCheck) { + requireNonNull(toCheck); + return internalList.stream().anyMatch(toCheck::isSameStudent); + } + + /** + * Adds a student to the list. + * The student must not already exist in the list. + */ + public void add(Student toAdd) { + requireNonNull(toAdd); + if (contains(toAdd)) { + throw new DuplicateStudentException(); + } + internalList.add(toAdd); + } + + /** + * Replaces the student {@code target} in the list with {@code editedStudent}. + * {@code target} must exist in the list. + * The student identity of {@code editedStudent} must not be the same as another existing student in the list. + */ + public void setStudent(Student target, Student editedStudent) { + requireAllNonNull(target, editedStudent); + + int index = internalList.indexOf(target); + if (index == -1) { + throw new StudentNotFoundException(); + } + + if (!target.isSameStudent(editedStudent) && contains(editedStudent)) { + throw new DuplicateStudentException(); + } + + internalList.set(index, editedStudent); + } + + /** + * Removes the equivalent student from the list. + * The student must exist in the list. + */ + public void remove(Student toRemove) { + requireNonNull(toRemove); + if (!internalList.remove(toRemove)) { + throw new StudentNotFoundException(); + } + } + + public void setStudents(UniqueStudentList replacement) { + requireNonNull(replacement); + internalList.setAll(replacement.internalList); + } + + /** + * Replaces the contents of this list with {@code students}. + * {@code students} must not contain duplicate students. + */ + public void setStudents(List students) { + requireAllNonNull(students); + if (!studentsAreUnique(students)) { + throw new DuplicateStudentException(); + } + + internalList.setAll(students); + } + + /** + * 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) { + if (other == this) { + return true; + } + + // instanceof handles nulls + if (!(other instanceof UniqueStudentList)) { + return false; + } + + UniqueStudentList otherUniqueStudentList = (UniqueStudentList) other; + return internalList.equals(otherUniqueStudentList.internalList); + } + + @Override + public int hashCode() { + return internalList.hashCode(); + } + + @Override + public String toString() { + return internalList.toString(); + } + + /** + * Returns true if {@code students} contains only unique students. + */ + private boolean studentsAreUnique(List students) { + for (int i = 0; i < students.size() - 1; i++) { + for (int j = i + 1; j < students.size(); j++) { + if (students.get(i).isSameStudent(students.get(j))) { + return false; + } + } + } + return true; + } +} diff --git a/src/main/java/seedu/address/model/student/exceptions/DuplicatePersonException.java b/src/main/java/seedu/address/model/student/exceptions/DuplicatePersonException.java deleted file mode 100644 index 8b4d730b669..00000000000 --- a/src/main/java/seedu/address/model/student/exceptions/DuplicatePersonException.java +++ /dev/null @@ -1,11 +0,0 @@ -package seedu.address.model.student.exceptions; - -/** - * Signals that the operation will result in duplicate Persons (Persons are considered duplicates if they have the same - * identity). - */ -public class DuplicatePersonException extends RuntimeException { - public DuplicatePersonException() { - super("Operation would result in duplicate persons"); - } -} diff --git a/src/main/java/seedu/address/model/student/exceptions/DuplicateStudentException.java b/src/main/java/seedu/address/model/student/exceptions/DuplicateStudentException.java new file mode 100644 index 00000000000..06f4f1c2189 --- /dev/null +++ b/src/main/java/seedu/address/model/student/exceptions/DuplicateStudentException.java @@ -0,0 +1,11 @@ +package seedu.address.model.student.exceptions; + +/** + * Signals that the operation will result in duplicate Students + * (Students are considered duplicates if they have the same identity). + */ +public class DuplicateStudentException extends RuntimeException { + public DuplicateStudentException() { + super("Operation would result in duplicate students"); + } +} diff --git a/src/main/java/seedu/address/model/student/exceptions/PersonNotFoundException.java b/src/main/java/seedu/address/model/student/exceptions/PersonNotFoundException.java deleted file mode 100644 index ef8a1357718..00000000000 --- a/src/main/java/seedu/address/model/student/exceptions/PersonNotFoundException.java +++ /dev/null @@ -1,6 +0,0 @@ -package seedu.address.model.student.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/student/exceptions/StudentNotFoundException.java b/src/main/java/seedu/address/model/student/exceptions/StudentNotFoundException.java new file mode 100644 index 00000000000..2b41e9e0296 --- /dev/null +++ b/src/main/java/seedu/address/model/student/exceptions/StudentNotFoundException.java @@ -0,0 +1,6 @@ +package seedu.address.model.student.exceptions; + +/** + * Signals that the operation is unable to find the specified student. + */ +public class StudentNotFoundException 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 4225eb47ee0..e27e61ac642 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -16,7 +16,7 @@ * Contains utility methods for populating {@code AddressBook} with sample data. */ public class SampleDataUtil { - public static Student[] getSamplePersons() { + public static Student[] getSampleStudents() { return new Student[] { new Student(new Name("Alex Yeoh"), new Phone("87438807"), new Email("alexyeoh@example.com"), getCourseSet("cs2103t")), @@ -35,8 +35,8 @@ public static Student[] getSamplePersons() { public static ReadOnlyAddressBook getSampleAddressBook() { AddressBook sampleAb = new AddressBook(); - for (Student samplePerson : getSamplePersons()) { - sampleAb.addPerson(samplePerson); + for (Student sampleStudent : getSampleStudents()) { + sampleAb.addStudent(sampleStudent); } return sampleAb; } diff --git a/src/main/java/seedu/address/storage/JsonAdaptedStudent.java b/src/main/java/seedu/address/storage/JsonAdaptedStudent.java index 3ae654a55f3..e80aa4d8463 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedStudent.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedStudent.java @@ -21,7 +21,7 @@ */ class JsonAdaptedStudent { - public static final String MISSING_FIELD_MESSAGE_FORMAT = "Person's %s field is missing!"; + public static final String MISSING_FIELD_MESSAGE_FORMAT = "Student's %s field is missing!"; private final String name; private final String phone; @@ -29,7 +29,7 @@ class JsonAdaptedStudent { private final List courses = new ArrayList<>(); /** - * Constructs a {@code JsonAdaptedPerson} with the given person details. + * Constructs a {@code JsonAdaptedStudent} with the given student details. */ @JsonCreator public JsonAdaptedStudent(@JsonProperty("name") String name, @JsonProperty("phone") String phone, @@ -44,7 +44,7 @@ public JsonAdaptedStudent(@JsonProperty("name") String name, @JsonProperty("phon } /** - * Converts a given {@code Person} into this class for Jackson use. + * Converts a given {@code Student} into this class for Jackson use. */ public JsonAdaptedStudent(Student source) { name = source.getName().fullName; @@ -56,15 +56,15 @@ public JsonAdaptedStudent(Student source) { } /** - * Converts this Jackson-friendly adapted person object into the model's {@code Person} object. + * Converts this Jackson-friendly adapted student object into the model's {@code Student} 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 student. */ public Student toModelType() throws IllegalValueException { - final List personCourses = new ArrayList<>(); + final List studentCourses = new ArrayList<>(); for (JsonAdaptedCourse course : courses) { - personCourses.add(course.toModelType()); + studentCourses.add(course.toModelType()); } if (name == null) { @@ -91,7 +91,7 @@ public Student toModelType() throws IllegalValueException { } final Email modelEmail = new Email(email); - final Set modelCourses = new HashSet<>(personCourses); + final Set modelCourses = new HashSet<>(studentCourses); return new Student(modelName, modelPhone, modelEmail, modelCourses); } diff --git a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java b/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java index fb0caf4b82f..921fb608a5c 100644 --- a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java +++ b/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java @@ -19,16 +19,16 @@ @JsonRootName(value = "addressbook") class JsonSerializableAddressBook { - public static final String MESSAGE_DUPLICATE_PERSON = "Persons list contains duplicate person(s)."; + public static final String MESSAGE_DUPLICATE_STUDENT = "Students list contains duplicate student(s)."; - private final List persons = new ArrayList<>(); + private final List students = new ArrayList<>(); /** - * Constructs a {@code JsonSerializableAddressBook} with the given persons. + * Constructs a {@code JsonSerializableAddressBook} with the given students. */ @JsonCreator - public JsonSerializableAddressBook(@JsonProperty("persons") List persons) { - this.persons.addAll(persons); + public JsonSerializableAddressBook(@JsonProperty("students") List students) { + this.students.addAll(students); } /** @@ -37,7 +37,7 @@ public JsonSerializableAddressBook(@JsonProperty("persons") List { private Logic logic; // Independent Ui parts residing in this Ui container - private PersonListPanel personListPanel; + private StudentListPanel studentListPanel; private ResultDisplay resultDisplay; private HelpWindow helpWindow; @@ -42,7 +42,7 @@ public class MainWindow extends UiPart { private MenuItem helpMenuItem; @FXML - private StackPane personListPanelPlaceholder; + private StackPane studentListPanelPlaceholder; @FXML private StackPane resultDisplayPlaceholder; @@ -110,8 +110,8 @@ private void setAccelerator(MenuItem menuItem, KeyCombination keyCombination) { * Fills up all the placeholders of this window. */ void fillInnerParts() { - personListPanel = new PersonListPanel(logic.getFilteredPersonList()); - personListPanelPlaceholder.getChildren().add(personListPanel.getRoot()); + studentListPanel = new StudentListPanel(logic.getFilteredStudentList()); + studentListPanelPlaceholder.getChildren().add(studentListPanel.getRoot()); resultDisplay = new ResultDisplay(); resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot()); @@ -163,8 +163,8 @@ private void handleExit() { primaryStage.hide(); } - public PersonListPanel getPersonListPanel() { - return personListPanel; + public StudentListPanel getStudentListPanel() { + return studentListPanel; } /** diff --git a/src/main/java/seedu/address/ui/PersonListPanel.java b/src/main/java/seedu/address/ui/PersonListPanel.java deleted file mode 100644 index 6ad5ccb4700..00000000000 --- a/src/main/java/seedu/address/ui/PersonListPanel.java +++ /dev/null @@ -1,49 +0,0 @@ -package seedu.address.ui; - -import java.util.logging.Logger; - -import javafx.collections.ObservableList; -import javafx.fxml.FXML; -import javafx.scene.control.ListCell; -import javafx.scene.control.ListView; -import javafx.scene.layout.Region; -import seedu.address.commons.core.LogsCenter; -import seedu.address.model.student.Student; - -/** - * Panel containing the list of persons. - */ -public class PersonListPanel extends UiPart { - private static final String FXML = "PersonListPanel.fxml"; - private final Logger logger = LogsCenter.getLogger(PersonListPanel.class); - - @FXML - private ListView personListView; - - /** - * Creates a {@code PersonListPanel} with the given {@code ObservableList}. - */ - public PersonListPanel(ObservableList personList) { - super(FXML); - personListView.setItems(personList); - personListView.setCellFactory(listView -> new PersonListViewCell()); - } - - /** - * Custom {@code ListCell} that displays the graphics of a {@code Person} using a {@code PersonCard}. - */ - class PersonListViewCell extends ListCell { - @Override - protected void updateItem(Student person, boolean empty) { - super.updateItem(person, empty); - - if (empty || person == null) { - setGraphic(null); - setText(null); - } else { - setGraphic(new PersonCard(person, getIndex() + 1).getRoot()); - } - } - } - -} diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/StudentCard.java similarity index 65% rename from src/main/java/seedu/address/ui/PersonCard.java rename to src/main/java/seedu/address/ui/StudentCard.java index dc95be6e9fd..a0722f01686 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/StudentCard.java @@ -10,11 +10,11 @@ import seedu.address.model.student.Student; /** - * An UI component that displays information of a {@code Person}. + * An UI component that displays information of a {@code Student}. */ -public class PersonCard extends UiPart { +public class StudentCard extends UiPart { - private static final String FXML = "PersonListCard.fxml"; + private static final String FXML = "StudentListCard.fxml"; /** * Note: Certain keywords such as "location" and "resources" are reserved keywords in JavaFX. @@ -24,7 +24,7 @@ public class PersonCard extends UiPart { * @see The issue on AddressBook level 4 */ - public final Student person; + public final Student student; @FXML private HBox cardPane; @@ -40,16 +40,16 @@ public class PersonCard extends UiPart { private FlowPane courses; /** - * Creates a {@code PersonCode} with the given {@code Person} and index to display. + * Creates a {@code StudentCode} with the given {@code Student} and index to display. */ - public PersonCard(Student person, int displayedIndex) { + public StudentCard(Student student, int displayedIndex) { super(FXML); - this.person = person; + this.student = student; id.setText(displayedIndex + ". "); - name.setText(person.getName().fullName); - phone.setText(person.getPhone().value); - email.setText(person.getEmail().value); - person.getCourses().stream() + name.setText(student.getName().fullName); + phone.setText(student.getPhone().value); + email.setText(student.getEmail().value); + student.getCourses().stream() .sorted(Comparator.comparing(course -> course.courseCode)) .forEach(course -> courses.getChildren().add(new Label(course.courseCode))); } diff --git a/src/main/java/seedu/address/ui/StudentListPanel.java b/src/main/java/seedu/address/ui/StudentListPanel.java new file mode 100644 index 00000000000..c906d3f82b3 --- /dev/null +++ b/src/main/java/seedu/address/ui/StudentListPanel.java @@ -0,0 +1,49 @@ +package seedu.address.ui; + +import java.util.logging.Logger; + +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.scene.control.ListCell; +import javafx.scene.control.ListView; +import javafx.scene.layout.Region; +import seedu.address.commons.core.LogsCenter; +import seedu.address.model.student.Student; + +/** + * Panel containing the list of students. + */ +public class StudentListPanel extends UiPart { + private static final String FXML = "StudentListPanel.fxml"; + private final Logger logger = LogsCenter.getLogger(StudentListPanel.class); + + @FXML + private ListView studentListView; + + /** + * Creates a {@code StudentListPanel} with the given {@code ObservableList}. + */ + public StudentListPanel(ObservableList studentList) { + super(FXML); + studentListView.setItems(studentList); + studentListView.setCellFactory(listView -> new StudentListViewCell()); + } + + /** + * Custom {@code ListCell} that displays the graphics of a {@code Student} using a {@code StudentCard}. + */ + class StudentListViewCell extends ListCell { + @Override + protected void updateItem(Student student, boolean empty) { + super.updateItem(student, empty); + + if (empty || student == null) { + setGraphic(null); + setText(null); + } else { + setGraphic(new StudentCard(student, getIndex() + 1).getRoot()); + } + } + } + +} diff --git a/src/main/resources/view/DarkTheme.css b/src/main/resources/view/DarkTheme.css index eac88aae7dc..cdbfb173394 100644 --- a/src/main/resources/view/DarkTheme.css +++ b/src/main/resources/view/DarkTheme.css @@ -328,7 +328,7 @@ -fx-text-fill: white; } -#filterField, #personListPanel, #personWebpage { +#filterField, #studentListPanel, #studentWebpage { -fx-effect: innershadow(gaussian, black, 10, 0, 0, 0); } diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml index 7778f666a0a..1832b2f96bf 100644 --- a/src/main/resources/view/MainWindow.fxml +++ b/src/main/resources/view/MainWindow.fxml @@ -46,11 +46,11 @@ - + - + diff --git a/src/main/resources/view/PersonListCard.fxml b/src/main/resources/view/StudentListCard.fxml similarity index 100% rename from src/main/resources/view/PersonListCard.fxml rename to src/main/resources/view/StudentListCard.fxml diff --git a/src/main/resources/view/PersonListPanel.fxml b/src/main/resources/view/StudentListPanel.fxml similarity index 77% rename from src/main/resources/view/PersonListPanel.fxml rename to src/main/resources/view/StudentListPanel.fxml index a1bb6bbace8..e164fbf0524 100644 --- a/src/main/resources/view/PersonListPanel.fxml +++ b/src/main/resources/view/StudentListPanel.fxml @@ -4,5 +4,5 @@ - + diff --git a/src/test/data/JsonAddressBookStorageTest/invalidAndValidPersonAddressBook.json b/src/test/data/JsonAddressBookStorageTest/invalidAndValidStudentAddressBook.json similarity index 66% rename from src/test/data/JsonAddressBookStorageTest/invalidAndValidPersonAddressBook.json rename to src/test/data/JsonAddressBookStorageTest/invalidAndValidStudentAddressBook.json index 6a4d2b7181c..4bf2f991bad 100644 --- a/src/test/data/JsonAddressBookStorageTest/invalidAndValidPersonAddressBook.json +++ b/src/test/data/JsonAddressBookStorageTest/invalidAndValidStudentAddressBook.json @@ -1,11 +1,11 @@ { - "persons": [ { - "name": "Valid Person", + "students": [ { + "name": "Valid Student", "phone": "9482424", "email": "hans@example.com", "address": "4th street" }, { - "name": "Person With Invalid Phone Field", + "name": "Student With Invalid Phone Field", "phone": "948asdf2424", "email": "hans@example.com", "address": "4th street" diff --git a/src/test/data/JsonAddressBookStorageTest/invalidPersonAddressBook.json b/src/test/data/JsonAddressBookStorageTest/invalidStudentAddressBook.json similarity index 54% rename from src/test/data/JsonAddressBookStorageTest/invalidPersonAddressBook.json rename to src/test/data/JsonAddressBookStorageTest/invalidStudentAddressBook.json index ccd21f7d1a9..3489ec31584 100644 --- a/src/test/data/JsonAddressBookStorageTest/invalidPersonAddressBook.json +++ b/src/test/data/JsonAddressBookStorageTest/invalidStudentAddressBook.json @@ -1,6 +1,6 @@ { - "persons": [ { - "name": "Person with invalid name field: Ha!ns Mu@ster", + "students": [ { + "name": "Student with invalid name field: Ha!ns Mu@ster", "phone": "9482424", "email": "hans@example.com", "address": "4th street" diff --git a/src/test/data/JsonSerializableAddressBookTest/duplicateStudentAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/duplicateStudentAddressBook.json index 314fd667dc1..334f14abefc 100644 --- a/src/test/data/JsonSerializableAddressBookTest/duplicateStudentAddressBook.json +++ b/src/test/data/JsonSerializableAddressBookTest/duplicateStudentAddressBook.json @@ -1,5 +1,5 @@ { - "persons": [ { + "students": [ { "name": "Alice Pauline", "phone": "94351253", "email": "alice@example.com", diff --git a/src/test/data/JsonSerializableAddressBookTest/invalidStudentAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/invalidStudentAddressBook.json index 671f3da654c..b8d9c1906fe 100644 --- a/src/test/data/JsonSerializableAddressBookTest/invalidStudentAddressBook.json +++ b/src/test/data/JsonSerializableAddressBookTest/invalidStudentAddressBook.json @@ -1,5 +1,5 @@ { - "persons": [ { + "students": [ { "name": "Hans Muster", "phone": "9482424", "email": "invalid@email!3e" diff --git a/src/test/data/JsonSerializableAddressBookTest/typicalStudentsAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/typicalStudentsAddressBook.json index 12cdefc0b72..c1c535c08f0 100644 --- a/src/test/data/JsonSerializableAddressBookTest/typicalStudentsAddressBook.json +++ b/src/test/data/JsonSerializableAddressBookTest/typicalStudentsAddressBook.json @@ -1,6 +1,6 @@ { - "_comment": "AddressBook save file which contains the same Person values as in TypicalPersons#getTypicalAddressBook()", - "persons" : [ { + "_comment": "AddressBook save file which contains the same Student values as in TypicalStudents#getTypicalAddressBook()", + "students" : [ { "name" : "Alice Pauline", "phone" : "94351253", "email" : "alice@example.com", diff --git a/src/test/java/seedu/address/commons/core/index/IndexTest.java b/src/test/java/seedu/address/commons/core/index/IndexTest.java index fc395ab964b..5e660d409b8 100644 --- a/src/test/java/seedu/address/commons/core/index/IndexTest.java +++ b/src/test/java/seedu/address/commons/core/index/IndexTest.java @@ -39,23 +39,23 @@ public void createZeroBasedIndex() { @Test public void equals() { - final Index fifthPersonIndex = Index.fromOneBased(5); + final Index fifthStudentIndex = Index.fromOneBased(5); // same values -> returns true - assertTrue(fifthPersonIndex.equals(Index.fromOneBased(5))); - assertTrue(fifthPersonIndex.equals(Index.fromZeroBased(4))); + assertTrue(fifthStudentIndex.equals(Index.fromOneBased(5))); + assertTrue(fifthStudentIndex.equals(Index.fromZeroBased(4))); // same object -> returns true - assertTrue(fifthPersonIndex.equals(fifthPersonIndex)); + assertTrue(fifthStudentIndex.equals(fifthStudentIndex)); // null -> returns false - assertFalse(fifthPersonIndex.equals(null)); + assertFalse(fifthStudentIndex.equals(null)); // different types -> returns false - assertFalse(fifthPersonIndex.equals(5.0f)); + assertFalse(fifthStudentIndex.equals(5.0f)); // different index -> returns false - assertFalse(fifthPersonIndex.equals(Index.fromOneBased(1))); + assertFalse(fifthStudentIndex.equals(Index.fromOneBased(1))); } @Test diff --git a/src/test/java/seedu/address/logic/LogicManagerTest.java b/src/test/java/seedu/address/logic/LogicManagerTest.java index 712ca6e4c7c..9347a94db4d 100644 --- a/src/test/java/seedu/address/logic/LogicManagerTest.java +++ b/src/test/java/seedu/address/logic/LogicManagerTest.java @@ -85,8 +85,8 @@ public void execute_storageThrowsAdException_throwsCommandException() { } @Test - public void getFilteredPersonList_modifyList_throwsUnsupportedOperationException() { - assertThrows(UnsupportedOperationException.class, () -> logic.getFilteredPersonList().remove(0)); + public void getFilteredStudentList_modifyList_throwsUnsupportedOperationException() { + assertThrows(UnsupportedOperationException.class, () -> logic.getFilteredStudentList().remove(0)); } /** @@ -169,9 +169,9 @@ public void saveAddressBook(ReadOnlyAddressBook addressBook, Path filePath) // Triggers the saveAddressBook method by executing an add command String addCommand = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY; - Student expectedPerson = new StudentBuilder(AMY).withCourses().build(); + Student expectedStudent = new StudentBuilder(AMY).withCourses().build(); ModelManager expectedModel = new ModelManager(); - expectedModel.addPerson(expectedPerson); + expectedModel.addStudent(expectedStudent); 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 8fb35b740e4..f4ff87328b6 100644 --- a/src/test/java/seedu/address/logic/commands/AddCommandIntegrationTest.java +++ b/src/test/java/seedu/address/logic/commands/AddCommandIntegrationTest.java @@ -27,22 +27,22 @@ public void setUp() { } @Test - public void execute_newPerson_success() { - Student validPerson = new StudentBuilder().build(); + public void execute_newStudent_success() { + Student validStudent = new StudentBuilder().build(); Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); - expectedModel.addPerson(validPerson); + expectedModel.addStudent(validStudent); - assertCommandSuccess(new AddCommand(validPerson), model, - String.format(AddCommand.MESSAGE_SUCCESS, Messages.format(validPerson)), + assertCommandSuccess(new AddCommand(validStudent), model, + String.format(AddCommand.MESSAGE_SUCCESS, Messages.format(validStudent)), expectedModel); } @Test - public void execute_duplicatePerson_throwsCommandException() { - Student personInList = model.getAddressBook().getPersonList().get(0); - assertCommandFailure(new AddCommand(personInList), model, - AddCommand.MESSAGE_DUPLICATE_PERSON); + public void execute_duplicateStudent_throwsCommandException() { + Student studentInList = model.getAddressBook().getStudentList().get(0); + assertCommandFailure(new AddCommand(studentInList), model, + AddCommand.MESSAGE_DUPLICATE_STUDENT); } } diff --git a/src/test/java/seedu/address/logic/commands/AddCommandTest.java b/src/test/java/seedu/address/logic/commands/AddCommandTest.java index 5c010b8fc64..d2036333e01 100644 --- a/src/test/java/seedu/address/logic/commands/AddCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/AddCommandTest.java @@ -28,29 +28,29 @@ public class AddCommandTest { @Test - public void constructor_nullPerson_throwsNullPointerException() { + public void constructor_nullStudent_throwsNullPointerException() { assertThrows(NullPointerException.class, () -> new AddCommand(null)); } @Test - public void execute_personAcceptedByModel_addSuccessful() throws Exception { - ModelStubAcceptingPersonAdded modelStub = new ModelStubAcceptingPersonAdded(); - Student validPerson = new StudentBuilder().build(); + public void execute_studentAcceptedByModel_addSuccessful() throws Exception { + ModelStubAcceptingStudentAdded modelStub = new ModelStubAcceptingStudentAdded(); + Student validStudent = new StudentBuilder().build(); - CommandResult commandResult = new AddCommand(validPerson).execute(modelStub); + CommandResult commandResult = new AddCommand(validStudent).execute(modelStub); - assertEquals(String.format(AddCommand.MESSAGE_SUCCESS, Messages.format(validPerson)), + assertEquals(String.format(AddCommand.MESSAGE_SUCCESS, Messages.format(validStudent)), commandResult.getFeedbackToUser()); - assertEquals(Arrays.asList(validPerson), modelStub.personsAdded); + assertEquals(Arrays.asList(validStudent), modelStub.studentsAdded); } @Test - public void execute_duplicatePerson_throwsCommandException() { - Student validPerson = new StudentBuilder().build(); - AddCommand addCommand = new AddCommand(validPerson); - ModelStub modelStub = new ModelStubWithPerson(validPerson); + public void execute_duplicateStudent_throwsCommandException() { + Student validStudent = new StudentBuilder().build(); + AddCommand addCommand = new AddCommand(validStudent); + ModelStub modelStub = new ModelStubWithStudent(validStudent); - assertThrows(CommandException.class, AddCommand.MESSAGE_DUPLICATE_PERSON, () -> addCommand.execute(modelStub)); + assertThrows(CommandException.class, AddCommand.MESSAGE_DUPLICATE_STUDENT, () -> addCommand.execute(modelStub)); } @Test @@ -73,7 +73,7 @@ public void equals() { // null -> returns false assertFalse(addAliceCommand.equals(null)); - // different person -> returns false + // different student -> returns false assertFalse(addAliceCommand.equals(addBobCommand)); } @@ -119,7 +119,7 @@ public void setAddressBookFilePath(Path addressBookFilePath) { } @Override - public void addPerson(Student person) { + public void addStudent(Student student) { throw new AssertionError("This method should not be called."); } @@ -134,65 +134,65 @@ public ReadOnlyAddressBook getAddressBook() { } @Override - public boolean hasPerson(Student person) { + public boolean hasStudent(Student student) { throw new AssertionError("This method should not be called."); } @Override - public void deletePerson(Student target) { + public void deleteStudent(Student target) { throw new AssertionError("This method should not be called."); } @Override - public void setPerson(Student target, Student editedPerson) { + public void setStudent(Student target, Student editedStudent) { throw new AssertionError("This method should not be called."); } @Override - public ObservableList getFilteredPersonList() { + public ObservableList getFilteredStudentList() { throw new AssertionError("This method should not be called."); } @Override - public void updateFilteredPersonList(Predicate predicate) { + public void updateFilteredStudentList(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 student. */ - private class ModelStubWithPerson extends ModelStub { - private final Student person; + private class ModelStubWithStudent extends ModelStub { + private final Student student; - ModelStubWithPerson(Student person) { - requireNonNull(person); - this.person = person; + ModelStubWithStudent(Student student) { + requireNonNull(student); + this.student = student; } @Override - public boolean hasPerson(Student person) { - requireNonNull(person); - return this.person.isSamePerson(person); + public boolean hasStudent(Student student) { + requireNonNull(student); + return this.student.isSameStudent(student); } } /** - * A Model stub that always accept the person being added. + * A Model stub that always accept the student being added. */ - private class ModelStubAcceptingPersonAdded extends ModelStub { - final ArrayList personsAdded = new ArrayList<>(); + private class ModelStubAcceptingStudentAdded extends ModelStub { + final ArrayList studentsAdded = new ArrayList<>(); @Override - public boolean hasPerson(Student person) { - requireNonNull(person); - return personsAdded.stream().anyMatch(person::isSamePerson); + public boolean hasStudent(Student student) { + requireNonNull(student); + return studentsAdded.stream().anyMatch(student::isSameStudent); } @Override - public void addPerson(Student person) { - requireNonNull(person); - personsAdded.add(person); + public void addStudent(Student student) { + requireNonNull(student); + studentsAdded.add(student); } @Override diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 7c7477f5666..a216ff6e90b 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -18,7 +18,7 @@ import seedu.address.model.Model; import seedu.address.model.student.NameContainsKeywordsPredicate; import seedu.address.model.student.Student; -import seedu.address.testutil.EditPersonDescriptorBuilder; +import seedu.address.testutil.EditStudentDescriptorBuilder; /** * Contains helper methods for testing commands. @@ -51,14 +51,14 @@ public class CommandTestUtil { public static final String PREAMBLE_WHITESPACE = "\t \r \n"; public static final String PREAMBLE_NON_EMPTY = "NonEmptyPreamble"; - public static final EditCommand.EditPersonDescriptor DESC_AMY; - public static final EditCommand.EditPersonDescriptor DESC_BOB; + public static final EditCommand.EditStudentDescriptor DESC_AMY; + public static final EditCommand.EditStudentDescriptor DESC_BOB; static { - DESC_AMY = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY) + DESC_AMY = new EditStudentDescriptorBuilder().withName(VALID_NAME_AMY) .withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY) .withCourses(VALID_COURSE_CS2103T).build(); - DESC_BOB = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB) + DESC_BOB = new EditStudentDescriptorBuilder().withName(VALID_NAME_BOB) .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB) .withCourses(VALID_COURSE_CS2101, VALID_COURSE_CS2103T).build(); } @@ -93,30 +93,30 @@ 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 student list and selected student 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.getFilteredStudentList()); assertThrows(CommandException.class, expectedMessage, () -> command.execute(actualModel)); assertEquals(expectedAddressBook, actualModel.getAddressBook()); - assertEquals(expectedFilteredList, actualModel.getFilteredPersonList()); + assertEquals(expectedFilteredList, actualModel.getFilteredStudentList()); } /** - * 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 student 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()); + public static void showStudentAtIndex(Model model, Index targetIndex) { + assertTrue(targetIndex.getZeroBased() < model.getFilteredStudentList().size()); - Student person = model.getFilteredPersonList().get(targetIndex.getZeroBased()); - final String[] splitName = person.getName().fullName.split("\\s+"); - model.updateFilteredPersonList(new NameContainsKeywordsPredicate(Arrays.asList(splitName[0]))); + Student student = model.getFilteredStudentList().get(targetIndex.getZeroBased()); + final String[] splitName = student.getName().fullName.split("\\s+"); + model.updateFilteredStudentList(new NameContainsKeywordsPredicate(Arrays.asList(splitName[0]))); - assertEquals(1, model.getFilteredPersonList().size()); + assertEquals(1, model.getFilteredStudentList().size()); } } diff --git a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java index 8cb0a591aca..14e880206de 100644 --- a/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/DeleteCommandTest.java @@ -5,9 +5,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; -import static seedu.address.logic.commands.CommandTestUtil.showPersonAtIndex; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; -import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PERSON; +import static seedu.address.logic.commands.CommandTestUtil.showStudentAtIndex; +import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_STUDENT; +import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_STUDENT; import static seedu.address.testutil.TypicalStudents.getTypicalAddressBook; import java.util.ArrayList; @@ -34,45 +34,45 @@ public class DeleteCommandTest { @Test public void execute_validIndexUnfilteredList_success() { - Student personToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + Student studentToDelete = model.getFilteredStudentList().get(INDEX_FIRST_STUDENT.getZeroBased()); Set firstIndexSet = new HashSet<>(); - firstIndexSet.add(INDEX_FIRST_PERSON); + firstIndexSet.add(INDEX_FIRST_STUDENT); DeleteCommand deleteCommand = new DeleteCommand(firstIndexSet); - String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, - Messages.format(personToDelete)); + String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_STUDENT_SUCCESS, + Messages.format(studentToDelete)); ModelManager expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); - expectedModel.deletePerson(personToDelete); + expectedModel.deleteStudent(studentToDelete); assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); } @Test public void execute_multipleValidIndexUnfilteredList_success() { - ArrayList personToDelete = new ArrayList<>(); - personToDelete.add(model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased())); - personToDelete.add(model.getFilteredPersonList().get(INDEX_SECOND_PERSON.getZeroBased())); + ArrayList studentToDelete = new ArrayList<>(); + studentToDelete.add(model.getFilteredStudentList().get(INDEX_FIRST_STUDENT.getZeroBased())); + studentToDelete.add(model.getFilteredStudentList().get(INDEX_SECOND_STUDENT.getZeroBased())); Set indexSet = new HashSet<>(); - indexSet.add(INDEX_FIRST_PERSON); - indexSet.add(INDEX_SECOND_PERSON); + indexSet.add(INDEX_FIRST_STUDENT); + indexSet.add(INDEX_SECOND_STUDENT); DeleteCommand deleteCommand = new DeleteCommand(indexSet); - String formattedDeletedPeople = personToDelete.stream() + String formattedDeletedPeople = studentToDelete.stream() .map(Messages::format) .collect(Collectors.joining("\n")); - String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, + String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_STUDENT_SUCCESS, formattedDeletedPeople); ModelManager expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); - personToDelete.forEach(expectedModel::deletePerson); + studentToDelete.forEach(expectedModel::deleteStudent); assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); } @Test public void execute_invalidIndexUnfilteredList_throwsCommandException() { - Index outOfBoundIndex = Index.fromOneBased(model.getFilteredPersonList().size() + 1); + Index outOfBoundIndex = Index.fromOneBased(model.getFilteredStudentList().size() + 1); Set outOfBoundIndexSet = new HashSet<>(); outOfBoundIndexSet.add(outOfBoundIndex); DeleteCommand deleteCommand = new DeleteCommand(outOfBoundIndexSet); @@ -83,8 +83,8 @@ public void execute_invalidIndexUnfilteredList_throwsCommandException() { @Test public void execute_multipleInvalidIndexUnfilteredList_throwsCommandException() { - Index outOfBoundIndex = Index.fromOneBased(model.getFilteredPersonList().size() + 1); - Index outOfBoundIndex2 = Index.fromOneBased(model.getFilteredPersonList().size() + 2); + Index outOfBoundIndex = Index.fromOneBased(model.getFilteredStudentList().size() + 1); + Index outOfBoundIndex2 = Index.fromOneBased(model.getFilteredStudentList().size() + 2); Set outOfBoundIndexSet = new HashSet<>(); outOfBoundIndexSet.add(outOfBoundIndex); outOfBoundIndexSet.add(outOfBoundIndex2); @@ -99,10 +99,10 @@ public void execute_multipleInvalidIndexUnfilteredList_throwsCommandException() @Test public void execute_oneInvalidIndexUnfilteredList_throwsCommandException() { - Index outOfBoundIndex = Index.fromOneBased(model.getFilteredPersonList().size() + 1); + Index outOfBoundIndex = Index.fromOneBased(model.getFilteredStudentList().size() + 1); Set outOfBoundIndexSet = new HashSet<>(); outOfBoundIndexSet.add(outOfBoundIndex); - outOfBoundIndexSet.add(INDEX_FIRST_PERSON); + outOfBoundIndexSet.add(INDEX_FIRST_STUDENT); DeleteCommand deleteCommand = new DeleteCommand(outOfBoundIndexSet); @@ -113,32 +113,32 @@ public void execute_oneInvalidIndexUnfilteredList_throwsCommandException() { @Test public void execute_validIndexFilteredList_success() { - showPersonAtIndex(model, INDEX_FIRST_PERSON); + showStudentAtIndex(model, INDEX_FIRST_STUDENT); - Student personToDelete = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + Student studentToDelete = model.getFilteredStudentList().get(INDEX_FIRST_STUDENT.getZeroBased()); Set firstIndexSet = new HashSet<>(); - firstIndexSet.add(INDEX_FIRST_PERSON); + firstIndexSet.add(INDEX_FIRST_STUDENT); DeleteCommand deleteCommand = new DeleteCommand(firstIndexSet); - String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, - Messages.format(personToDelete)); + String expectedMessage = String.format(DeleteCommand.MESSAGE_DELETE_STUDENT_SUCCESS, + Messages.format(studentToDelete)); Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); - expectedModel.deletePerson(personToDelete); - showNoPerson(expectedModel); + expectedModel.deleteStudent(studentToDelete); + showNoStudent(expectedModel); assertCommandSuccess(deleteCommand, model, expectedMessage, expectedModel); } @Test public void execute_invalidIndexFilteredList_throwsCommandException() { - showPersonAtIndex(model, INDEX_FIRST_PERSON); + showStudentAtIndex(model, INDEX_FIRST_STUDENT); - Index outOfBoundIndex = INDEX_SECOND_PERSON; + Index outOfBoundIndex = INDEX_SECOND_STUDENT; // ensures that outOfBoundIndex is still in bounds of address book list - assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getPersonList().size()); + assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getStudentList().size()); Set outOfBoundIndexSet = new HashSet<>(); - outOfBoundIndexSet.add(INDEX_SECOND_PERSON); + outOfBoundIndexSet.add(INDEX_SECOND_STUDENT); DeleteCommand deleteCommand = new DeleteCommand(outOfBoundIndexSet); assertCommandFailure(deleteCommand, model, String.format(Messages.MESSAGE_INVALID_INDEX_SHOWN, @@ -148,9 +148,9 @@ public void execute_invalidIndexFilteredList_throwsCommandException() { @Test public void equals() { Set firstIndexSet = new HashSet<>(); - firstIndexSet.add(INDEX_FIRST_PERSON); + firstIndexSet.add(INDEX_FIRST_STUDENT); Set secondIndexSet = new HashSet<>(); - secondIndexSet.add(INDEX_SECOND_PERSON); + secondIndexSet.add(INDEX_SECOND_STUDENT); DeleteCommand deleteFirstCommand = new DeleteCommand(firstIndexSet); DeleteCommand deleteSecondCommand = new DeleteCommand(secondIndexSet); @@ -159,7 +159,7 @@ public void equals() { // same values -> returns true Set firstIndexSetCopy = new HashSet<>(); - firstIndexSetCopy.add(INDEX_FIRST_PERSON); + firstIndexSetCopy.add(INDEX_FIRST_STUDENT); DeleteCommand deleteFirstCommandCopy = new DeleteCommand(firstIndexSetCopy); assertTrue(deleteFirstCommand.equals(deleteFirstCommandCopy)); @@ -169,7 +169,7 @@ public void equals() { // null -> returns false assertFalse(deleteFirstCommand.equals(null)); - // different person -> returns false + // different student -> returns false assertFalse(deleteFirstCommand.equals(deleteSecondCommand)); } @@ -177,7 +177,7 @@ public void equals() { public void toStringMethod() { Index targetIndex = Index.fromOneBased(1); Set targetIndexSet = new HashSet<>(); - targetIndexSet.add(INDEX_FIRST_PERSON); + targetIndexSet.add(INDEX_FIRST_STUDENT); DeleteCommand deleteCommand = new DeleteCommand(targetIndexSet); String expected = DeleteCommand.class.getCanonicalName() + "{targetIndices=" + targetIndexSet + "}"; assertEquals(expected, deleteCommand.toString()); @@ -186,9 +186,9 @@ public void toStringMethod() { /** * Updates {@code model}'s filtered list to show no one. */ - private void showNoPerson(Model model) { - model.updateFilteredPersonList(p -> false); + private void showNoStudent(Model model) { + model.updateFilteredStudentList(p -> false); - assertTrue(model.getFilteredPersonList().isEmpty()); + assertTrue(model.getFilteredStudentList().isEmpty()); } } diff --git a/src/test/java/seedu/address/logic/commands/EditCommandTest.java b/src/test/java/seedu/address/logic/commands/EditCommandTest.java index 0e00f8fe5db..26014162569 100644 --- a/src/test/java/seedu/address/logic/commands/EditCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/EditCommandTest.java @@ -10,22 +10,22 @@ import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; -import static seedu.address.logic.commands.CommandTestUtil.showPersonAtIndex; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; -import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PERSON; +import static seedu.address.logic.commands.CommandTestUtil.showStudentAtIndex; +import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_STUDENT; +import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_STUDENT; import static seedu.address.testutil.TypicalStudents.getTypicalAddressBook; import org.junit.jupiter.api.Test; import seedu.address.commons.core.index.Index; import seedu.address.logic.Messages; -import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; +import seedu.address.logic.commands.EditCommand.EditStudentDescriptor; import seedu.address.model.AddressBook; import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.UserPrefs; import seedu.address.model.student.Student; -import seedu.address.testutil.EditPersonDescriptorBuilder; +import seedu.address.testutil.EditStudentDescriptorBuilder; import seedu.address.testutil.StudentBuilder; /** @@ -37,45 +37,48 @@ public class EditCommandTest { @Test public void execute_allFieldsSpecifiedUnfilteredList_success() { - Student editedPerson = new StudentBuilder().build(); - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(editedPerson).build(); - EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, descriptor); + Student editedStudent = new StudentBuilder().build(); + EditStudentDescriptor descriptor = new EditStudentDescriptorBuilder(editedStudent).build(); + EditCommand editCommand = new EditCommand(INDEX_FIRST_STUDENT, descriptor); - String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); + String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_STUDENT_SUCCESS, + Messages.format(editedStudent)); Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); - expectedModel.setPerson(model.getFilteredPersonList().get(0), editedPerson); + expectedModel.setStudent(model.getFilteredStudentList().get(0), editedStudent); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); } @Test public void execute_someFieldsSpecifiedUnfilteredList_success() { - Index indexLastPerson = Index.fromOneBased(model.getFilteredPersonList().size()); - Student lastPerson = model.getFilteredPersonList().get(indexLastPerson.getZeroBased()); + Index indexLastStudent = Index.fromOneBased(model.getFilteredStudentList().size()); + Student lastStudent = model.getFilteredStudentList().get(indexLastStudent.getZeroBased()); - StudentBuilder personInList = new StudentBuilder(lastPerson); - Student editedPerson = personInList.withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) + StudentBuilder studentInList = new StudentBuilder(lastStudent); + Student editedStudent = studentInList.withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) .withCourses(VALID_COURSE_CS2103T).build(); - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB) + EditStudentDescriptor descriptor = new EditStudentDescriptorBuilder().withName(VALID_NAME_BOB) .withPhone(VALID_PHONE_BOB).withCourses(VALID_COURSE_CS2103T).build(); - EditCommand editCommand = new EditCommand(indexLastPerson, descriptor); + EditCommand editCommand = new EditCommand(indexLastStudent, descriptor); - String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); + String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_STUDENT_SUCCESS, + Messages.format(editedStudent)); Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); - expectedModel.setPerson(lastPerson, editedPerson); + expectedModel.setStudent(lastStudent, editedStudent); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); } @Test public void execute_noFieldSpecifiedUnfilteredList_success() { - EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, new EditPersonDescriptor()); - Student editedPerson = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); + EditCommand editCommand = new EditCommand(INDEX_FIRST_STUDENT, new EditStudentDescriptor()); + Student editedStudent = model.getFilteredStudentList().get(INDEX_FIRST_STUDENT.getZeroBased()); - String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); + String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_STUDENT_SUCCESS, + Messages.format(editedStudent)); Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); @@ -84,49 +87,50 @@ public void execute_noFieldSpecifiedUnfilteredList_success() { @Test public void execute_filteredList_success() { - showPersonAtIndex(model, INDEX_FIRST_PERSON); + showStudentAtIndex(model, INDEX_FIRST_STUDENT); - Student personInFilteredList = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); - Student editedPerson = new StudentBuilder(personInFilteredList).withName(VALID_NAME_BOB).build(); - EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, - new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB).build()); + Student studentInFilteredList = model.getFilteredStudentList().get(INDEX_FIRST_STUDENT.getZeroBased()); + Student editedStudent = new StudentBuilder(studentInFilteredList).withName(VALID_NAME_BOB).build(); + EditCommand editCommand = new EditCommand(INDEX_FIRST_STUDENT, + new EditStudentDescriptorBuilder().withName(VALID_NAME_BOB).build()); - String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)); + String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_STUDENT_SUCCESS, + Messages.format(editedStudent)); Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); - expectedModel.setPerson(model.getFilteredPersonList().get(0), editedPerson); + expectedModel.setStudent(model.getFilteredStudentList().get(0), editedStudent); assertCommandSuccess(editCommand, model, expectedMessage, expectedModel); } @Test - public void execute_duplicatePersonUnfilteredList_failure() { - Student firstPerson = model.getFilteredPersonList().get(INDEX_FIRST_PERSON.getZeroBased()); - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(firstPerson).build(); - EditCommand editCommand = new EditCommand(INDEX_SECOND_PERSON, descriptor); + public void execute_duplicateStudentUnfilteredList_failure() { + Student firstStudent = model.getFilteredStudentList().get(INDEX_FIRST_STUDENT.getZeroBased()); + EditStudentDescriptor descriptor = new EditStudentDescriptorBuilder(firstStudent).build(); + EditCommand editCommand = new EditCommand(INDEX_SECOND_STUDENT, descriptor); - assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_PERSON); + assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_STUDENT); } @Test - public void execute_duplicatePersonFilteredList_failure() { - showPersonAtIndex(model, INDEX_FIRST_PERSON); + public void execute_duplicateStudentFilteredList_failure() { + showStudentAtIndex(model, INDEX_FIRST_STUDENT); - // edit person in filtered list into a duplicate in address book - Student personInList = model.getAddressBook().getPersonList().get(INDEX_SECOND_PERSON.getZeroBased()); - EditCommand editCommand = new EditCommand(INDEX_FIRST_PERSON, - new EditPersonDescriptorBuilder(personInList).build()); + // edit student in filtered list into a duplicate in address book + Student studentInList = model.getAddressBook().getStudentList().get(INDEX_SECOND_STUDENT.getZeroBased()); + EditCommand editCommand = new EditCommand(INDEX_FIRST_STUDENT, + new EditStudentDescriptorBuilder(studentInList).build()); - assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_PERSON); + assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_STUDENT); } @Test - public void execute_invalidPersonIndexUnfilteredList_failure() { - Index outOfBoundIndex = Index.fromOneBased(model.getFilteredPersonList().size() + 1); - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB).build(); + public void execute_invalidStudentIndexUnfilteredList_failure() { + Index outOfBoundIndex = Index.fromOneBased(model.getFilteredStudentList().size() + 1); + EditStudentDescriptor descriptor = new EditStudentDescriptorBuilder().withName(VALID_NAME_BOB).build(); EditCommand editCommand = new EditCommand(outOfBoundIndex, descriptor); - assertCommandFailure(editCommand, model, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + assertCommandFailure(editCommand, model, Messages.MESSAGE_INVALID_STUDENT_DISPLAYED_INDEX); } /** @@ -134,25 +138,25 @@ public void execute_invalidPersonIndexUnfilteredList_failure() { * but smaller than size of address book */ @Test - public void execute_invalidPersonIndexFilteredList_failure() { - showPersonAtIndex(model, INDEX_FIRST_PERSON); - Index outOfBoundIndex = INDEX_SECOND_PERSON; + public void execute_invalidStudentIndexFilteredList_failure() { + showStudentAtIndex(model, INDEX_FIRST_STUDENT); + Index outOfBoundIndex = INDEX_SECOND_STUDENT; // ensures that outOfBoundIndex is still in bounds of address book list - assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getPersonList().size()); + assertTrue(outOfBoundIndex.getZeroBased() < model.getAddressBook().getStudentList().size()); EditCommand editCommand = new EditCommand(outOfBoundIndex, - new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB).build()); + new EditStudentDescriptorBuilder().withName(VALID_NAME_BOB).build()); - assertCommandFailure(editCommand, model, Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + assertCommandFailure(editCommand, model, Messages.MESSAGE_INVALID_STUDENT_DISPLAYED_INDEX); } @Test public void equals() { - final EditCommand standardCommand = new EditCommand(INDEX_FIRST_PERSON, DESC_AMY); + final EditCommand standardCommand = new EditCommand(INDEX_FIRST_STUDENT, DESC_AMY); // same values -> returns true - EditPersonDescriptor copyDescriptor = new EditPersonDescriptor(DESC_AMY); - EditCommand commandWithSameValues = new EditCommand(INDEX_FIRST_PERSON, copyDescriptor); + EditStudentDescriptor copyDescriptor = new EditStudentDescriptor(DESC_AMY); + EditCommand commandWithSameValues = new EditCommand(INDEX_FIRST_STUDENT, copyDescriptor); assertTrue(standardCommand.equals(commandWithSameValues)); // same object -> returns true @@ -165,19 +169,19 @@ public void equals() { assertFalse(standardCommand.equals(new ClearCommand())); // different index -> returns false - assertFalse(standardCommand.equals(new EditCommand(INDEX_SECOND_PERSON, DESC_AMY))); + assertFalse(standardCommand.equals(new EditCommand(INDEX_SECOND_STUDENT, DESC_AMY))); // different descriptor -> returns false - assertFalse(standardCommand.equals(new EditCommand(INDEX_FIRST_PERSON, DESC_BOB))); + assertFalse(standardCommand.equals(new EditCommand(INDEX_FIRST_STUDENT, DESC_BOB))); } @Test public void toStringMethod() { Index index = Index.fromOneBased(1); - EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor(); - EditCommand editCommand = new EditCommand(index, editPersonDescriptor); - String expected = EditCommand.class.getCanonicalName() + "{index=" + index + ", editPersonDescriptor=" - + editPersonDescriptor + "}"; + EditStudentDescriptor editStudentDescriptor = new EditStudentDescriptor(); + EditCommand editCommand = new EditCommand(index, editStudentDescriptor); + String expected = EditCommand.class.getCanonicalName() + "{index=" + index + ", editStudentDescriptor=" + + editStudentDescriptor + "}"; assertEquals(expected, editCommand.toString()); } diff --git a/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java b/src/test/java/seedu/address/logic/commands/EditStudentDescriptorTest.java similarity index 56% rename from src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java rename to src/test/java/seedu/address/logic/commands/EditStudentDescriptorTest.java index d91bb21ffb7..d7e54a8b1a9 100644 --- a/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java +++ b/src/test/java/seedu/address/logic/commands/EditStudentDescriptorTest.java @@ -12,15 +12,15 @@ import org.junit.jupiter.api.Test; -import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; -import seedu.address.testutil.EditPersonDescriptorBuilder; +import seedu.address.logic.commands.EditCommand.EditStudentDescriptor; +import seedu.address.testutil.EditStudentDescriptorBuilder; -public class EditPersonDescriptorTest { +public class EditStudentDescriptorTest { @Test public void equals() { // same values -> returns true - EditPersonDescriptor descriptorWithSameValues = new EditPersonDescriptor(DESC_AMY); + EditStudentDescriptor descriptorWithSameValues = new EditStudentDescriptor(DESC_AMY); assertTrue(DESC_AMY.equals(descriptorWithSameValues)); // same object -> returns true @@ -36,30 +36,30 @@ public void equals() { assertFalse(DESC_AMY.equals(DESC_BOB)); // different name -> returns false - EditPersonDescriptor editedAmy = new EditPersonDescriptorBuilder(DESC_AMY).withName(VALID_NAME_BOB).build(); + EditStudentDescriptor editedAmy = new EditStudentDescriptorBuilder(DESC_AMY).withName(VALID_NAME_BOB).build(); assertFalse(DESC_AMY.equals(editedAmy)); // different phone -> returns false - editedAmy = new EditPersonDescriptorBuilder(DESC_AMY).withPhone(VALID_PHONE_BOB).build(); + editedAmy = new EditStudentDescriptorBuilder(DESC_AMY).withPhone(VALID_PHONE_BOB).build(); assertFalse(DESC_AMY.equals(editedAmy)); // different email -> returns false - editedAmy = new EditPersonDescriptorBuilder(DESC_AMY).withEmail(VALID_EMAIL_BOB).build(); + editedAmy = new EditStudentDescriptorBuilder(DESC_AMY).withEmail(VALID_EMAIL_BOB).build(); assertFalse(DESC_AMY.equals(editedAmy)); // different tags -> returns false - editedAmy = new EditPersonDescriptorBuilder(DESC_AMY).withCourses(VALID_COURSE_CS2101).build(); + editedAmy = new EditStudentDescriptorBuilder(DESC_AMY).withCourses(VALID_COURSE_CS2101).build(); assertFalse(DESC_AMY.equals(editedAmy)); } @Test public void toStringMethod() { - EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor(); - String expected = EditPersonDescriptor.class.getCanonicalName() + "{name=" - + editPersonDescriptor.getName().orElse(null) + ", phone=" - + editPersonDescriptor.getPhone().orElse(null) + ", email=" - + editPersonDescriptor.getEmail().orElse(null) + ", courses=" - + editPersonDescriptor.getCourses().orElse(null) + "}"; - assertEquals(expected, editPersonDescriptor.toString()); + EditStudentDescriptor editStudentDescriptor = new EditStudentDescriptor(); + String expected = EditStudentDescriptor.class.getCanonicalName() + "{name=" + + editStudentDescriptor.getName().orElse(null) + ", phone=" + + editStudentDescriptor.getPhone().orElse(null) + ", email=" + + editStudentDescriptor.getEmail().orElse(null) + ", courses=" + + editStudentDescriptor.getCourses().orElse(null) + "}"; + assertEquals(expected, editStudentDescriptor.toString()); } } diff --git a/src/test/java/seedu/address/logic/commands/FindCommandTest.java b/src/test/java/seedu/address/logic/commands/FindCommandTest.java index b335e937cb9..7f5d3f4a48c 100644 --- a/src/test/java/seedu/address/logic/commands/FindCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/FindCommandTest.java @@ -3,7 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.logic.Messages.MESSAGE_PERSONS_LISTED_OVERVIEW; +import static seedu.address.logic.Messages.MESSAGE_STUDENTS_LISTED_OVERVIEW; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; import static seedu.address.testutil.TypicalStudents.CARL; import static seedu.address.testutil.TypicalStudents.ELLE; @@ -50,28 +50,28 @@ public void equals() { // null -> returns false assertFalse(findFirstCommand.equals(null)); - // different person -> returns false + // different student -> returns false assertFalse(findFirstCommand.equals(findSecondCommand)); } @Test - public void execute_zeroKeywords_noPersonFound() { - String expectedMessage = String.format(MESSAGE_PERSONS_LISTED_OVERVIEW, 0); + public void execute_zeroKeywords_noStudentFound() { + String expectedMessage = String.format(MESSAGE_STUDENTS_LISTED_OVERVIEW, 0); NameContainsKeywordsPredicate predicate = preparePredicate(" "); FindCommand command = new FindCommand(predicate); - expectedModel.updateFilteredPersonList(predicate); + expectedModel.updateFilteredStudentList(predicate); assertCommandSuccess(command, model, expectedMessage, expectedModel); - assertEquals(Collections.emptyList(), model.getFilteredPersonList()); + assertEquals(Collections.emptyList(), model.getFilteredStudentList()); } @Test - public void execute_multipleKeywords_multiplePersonsFound() { - String expectedMessage = String.format(MESSAGE_PERSONS_LISTED_OVERVIEW, 3); + public void execute_multipleKeywords_multipleStudentsFound() { + String expectedMessage = String.format(MESSAGE_STUDENTS_LISTED_OVERVIEW, 3); NameContainsKeywordsPredicate predicate = preparePredicate("Kurz Elle Kunz"); FindCommand command = new FindCommand(predicate); - expectedModel.updateFilteredPersonList(predicate); + expectedModel.updateFilteredStudentList(predicate); assertCommandSuccess(command, model, expectedMessage, expectedModel); - assertEquals(Arrays.asList(CARL, ELLE, FIONA), model.getFilteredPersonList()); + assertEquals(Arrays.asList(CARL, ELLE, FIONA), model.getFilteredStudentList()); } @Test diff --git a/src/test/java/seedu/address/logic/commands/ListCommandTest.java b/src/test/java/seedu/address/logic/commands/ListCommandTest.java index a89176acc3b..b6c00c69f86 100644 --- a/src/test/java/seedu/address/logic/commands/ListCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/ListCommandTest.java @@ -1,8 +1,8 @@ package seedu.address.logic.commands; import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; -import static seedu.address.logic.commands.CommandTestUtil.showPersonAtIndex; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; +import static seedu.address.logic.commands.CommandTestUtil.showStudentAtIndex; +import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_STUDENT; import static seedu.address.testutil.TypicalStudents.getTypicalAddressBook; import org.junit.jupiter.api.BeforeEach; @@ -33,7 +33,7 @@ public void execute_listIsNotFiltered_showsSameList() { @Test public void execute_listIsFiltered_showsEverything() { - showPersonAtIndex(model, INDEX_FIRST_PERSON); + showStudentAtIndex(model, INDEX_FIRST_STUDENT); assertCommandSuccess(new ListCommand(), model, ListCommand.MESSAGE_SUCCESS, expectedModel); } } diff --git a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java index 46df2cb8657..479c1934941 100644 --- a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java @@ -44,80 +44,80 @@ public class AddCommandParserTest { @Test public void parse_allFieldsPresent_success() { - Student expectedPerson = new StudentBuilder(BOB).withCourses(VALID_COURSE_CS2103T).build(); + Student expectedStudent = new StudentBuilder(BOB).withCourses(VALID_COURSE_CS2103T).build(); // whitespace only preamble assertParseSuccess(parser, PREAMBLE_WHITESPACE + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB - + COURSE_DESC_CS2103T, new AddCommand(expectedPerson)); + + COURSE_DESC_CS2103T, new AddCommand(expectedStudent)); // multiple COURSEs - all accepted - Student expectedPersonMultipleCourses = new StudentBuilder(BOB).withCourses(VALID_COURSE_CS2103T, + Student expectedStudentMultipleCourses = new StudentBuilder(BOB).withCourses(VALID_COURSE_CS2103T, VALID_COURSE_CS2101) .build(); assertParseSuccess(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + COURSE_DESC_CS2101 + COURSE_DESC_CS2103T, - new AddCommand(expectedPersonMultipleCourses)); + new AddCommand(expectedStudentMultipleCourses)); } @Test public void parse_repeatedNonCourseValue_failure() { - String validExpectedPersonString = NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + String validExpectedStudentString = NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + COURSE_DESC_CS2103T; // multiple names - assertParseFailure(parser, NAME_DESC_AMY + validExpectedPersonString, + assertParseFailure(parser, NAME_DESC_AMY + validExpectedStudentString, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_NAME)); // multiple phones - assertParseFailure(parser, PHONE_DESC_AMY + validExpectedPersonString, + assertParseFailure(parser, PHONE_DESC_AMY + validExpectedStudentString, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE)); // multiple emails - assertParseFailure(parser, EMAIL_DESC_AMY + validExpectedPersonString, + assertParseFailure(parser, EMAIL_DESC_AMY + validExpectedStudentString, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_EMAIL)); // multiple fields repeated assertParseFailure(parser, - validExpectedPersonString + PHONE_DESC_AMY + EMAIL_DESC_AMY + NAME_DESC_AMY - + validExpectedPersonString, + validExpectedStudentString + PHONE_DESC_AMY + EMAIL_DESC_AMY + NAME_DESC_AMY + + validExpectedStudentString, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_NAME, PREFIX_EMAIL, PREFIX_PHONE)); // invalid value followed by valid value // invalid name - assertParseFailure(parser, INVALID_NAME_DESC + validExpectedPersonString, + assertParseFailure(parser, INVALID_NAME_DESC + validExpectedStudentString, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_NAME)); // invalid email - assertParseFailure(parser, INVALID_EMAIL_DESC + validExpectedPersonString, + assertParseFailure(parser, INVALID_EMAIL_DESC + validExpectedStudentString, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_EMAIL)); // invalid phone - assertParseFailure(parser, INVALID_PHONE_DESC + validExpectedPersonString, + assertParseFailure(parser, INVALID_PHONE_DESC + validExpectedStudentString, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE)); // valid value followed by invalid value // invalid name - assertParseFailure(parser, validExpectedPersonString + INVALID_NAME_DESC, + assertParseFailure(parser, validExpectedStudentString + INVALID_NAME_DESC, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_NAME)); // invalid email - assertParseFailure(parser, validExpectedPersonString + INVALID_EMAIL_DESC, + assertParseFailure(parser, validExpectedStudentString + INVALID_EMAIL_DESC, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_EMAIL)); // invalid phone - assertParseFailure(parser, validExpectedPersonString + INVALID_PHONE_DESC, + assertParseFailure(parser, validExpectedStudentString + INVALID_PHONE_DESC, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE)); } @Test public void parse_optionalFieldsMissing_success() { // zero COURSEs - Student expectedPerson = new StudentBuilder(AMY).withCourses().build(); + Student expectedStudent = new StudentBuilder(AMY).withCourses().build(); assertParseSuccess(parser, NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY, - new AddCommand(expectedPerson)); + new AddCommand(expectedStudent)); } @Test diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java index 4d91c464d2b..e728455e285 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java @@ -6,7 +6,7 @@ import static seedu.address.logic.Messages.MESSAGE_UNKNOWN_COMMAND; import static seedu.address.logic.parser.CliSyntax.PREFIX_DELETE_INDEX; import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; +import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_STUDENT; import java.util.Arrays; import java.util.HashSet; @@ -21,7 +21,7 @@ import seedu.address.logic.commands.ClearCommand; import seedu.address.logic.commands.DeleteCommand; import seedu.address.logic.commands.EditCommand; -import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; +import seedu.address.logic.commands.EditCommand.EditStudentDescriptor; import seedu.address.logic.commands.ExitCommand; import seedu.address.logic.commands.FindCommand; import seedu.address.logic.commands.HelpCommand; @@ -29,7 +29,7 @@ import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.student.NameContainsKeywordsPredicate; import seedu.address.model.student.Student; -import seedu.address.testutil.EditPersonDescriptorBuilder; +import seedu.address.testutil.EditStudentDescriptorBuilder; import seedu.address.testutil.StudentBuilder; import seedu.address.testutil.StudentUtil; @@ -40,9 +40,9 @@ public class AddressBookParserTest { @Test public void parseCommand_add() throws Exception { - Student person = new StudentBuilder().build(); - AddCommand command = (AddCommand) parser.parseCommand(StudentUtil.getAddCommand(person)); - assertEquals(new AddCommand(person), command); + Student student = new StudentBuilder().build(); + AddCommand command = (AddCommand) parser.parseCommand(StudentUtil.getAddCommand(student)); + assertEquals(new AddCommand(student), command); } @Test @@ -54,19 +54,19 @@ public void parseCommand_clear() throws Exception { @Test public void parseCommand_delete() throws Exception { DeleteCommand command = (DeleteCommand) parser.parseCommand( - DeleteCommand.COMMAND_WORD + " " + PREFIX_DELETE_INDEX + INDEX_FIRST_PERSON.getOneBased()); + DeleteCommand.COMMAND_WORD + " " + PREFIX_DELETE_INDEX + INDEX_FIRST_STUDENT.getOneBased()); Set firstIndexSet = new HashSet<>(); - firstIndexSet.add(INDEX_FIRST_PERSON); + firstIndexSet.add(INDEX_FIRST_STUDENT); assertEquals(new DeleteCommand(firstIndexSet), command); } @Test public void parseCommand_edit() throws Exception { - Student person = new StudentBuilder().build(); - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(person).build(); + Student student = new StudentBuilder().build(); + EditStudentDescriptor descriptor = new EditStudentDescriptorBuilder(student).build(); EditCommand command = (EditCommand) parser.parseCommand(EditCommand.COMMAND_WORD + " " - + INDEX_FIRST_PERSON.getOneBased() + " " + StudentUtil.getEditPersonDescriptorDetails(descriptor)); - assertEquals(new EditCommand(INDEX_FIRST_PERSON, descriptor), command); + + INDEX_FIRST_STUDENT.getOneBased() + " " + StudentUtil.getEditStudentDescriptorDetails(descriptor)); + assertEquals(new EditCommand(INDEX_FIRST_STUDENT, descriptor), command); } @Test diff --git a/src/test/java/seedu/address/logic/parser/DeleteCommandParserTest.java b/src/test/java/seedu/address/logic/parser/DeleteCommandParserTest.java index a64582af53c..fd0ccfef1c7 100644 --- a/src/test/java/seedu/address/logic/parser/DeleteCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/DeleteCommandParserTest.java @@ -4,8 +4,8 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_DELETE_INDEX; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; -import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PERSON; +import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_STUDENT; +import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_STUDENT; import java.util.HashSet; import java.util.Set; @@ -29,15 +29,15 @@ public class DeleteCommandParserTest { @Test public void parse_singleDeleteValidArgs_returnsDeleteCommand() { Set firstIndexSet = new HashSet<>(); - firstIndexSet.add(INDEX_FIRST_PERSON); + firstIndexSet.add(INDEX_FIRST_STUDENT); assertParseSuccess(parser, " " + PREFIX_DELETE_INDEX + "1", new DeleteCommand(firstIndexSet)); } @Test public void parse_multiDeleteValidArgs_returnsDeleteCommand() { Set indexSet = new HashSet<>(); - indexSet.add(INDEX_FIRST_PERSON); - indexSet.add(INDEX_SECOND_PERSON); + indexSet.add(INDEX_FIRST_STUDENT); + indexSet.add(INDEX_SECOND_STUDENT); assertParseSuccess(parser, " " + PREFIX_DELETE_INDEX + "1 " + PREFIX_DELETE_INDEX + "2 ", new DeleteCommand(indexSet)); } diff --git a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java index 54cd3392461..fa75e94c0ec 100644 --- a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java @@ -23,21 +23,21 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; -import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_PERSON; -import static seedu.address.testutil.TypicalIndexes.INDEX_THIRD_PERSON; +import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_STUDENT; +import static seedu.address.testutil.TypicalIndexes.INDEX_SECOND_STUDENT; +import static seedu.address.testutil.TypicalIndexes.INDEX_THIRD_STUDENT; import org.junit.jupiter.api.Test; import seedu.address.commons.core.index.Index; import seedu.address.logic.Messages; import seedu.address.logic.commands.EditCommand; -import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; +import seedu.address.logic.commands.EditCommand.EditStudentDescriptor; import seedu.address.model.course.Course; import seedu.address.model.student.Email; import seedu.address.model.student.Name; import seedu.address.model.student.Phone; -import seedu.address.testutil.EditPersonDescriptorBuilder; +import seedu.address.testutil.EditStudentDescriptorBuilder; public class EditCommandParserTest { @@ -85,7 +85,7 @@ public void parse_invalidValue_failure() { // invalid phone followed by valid email assertParseFailure(parser, "1" + INVALID_PHONE_DESC + EMAIL_DESC_AMY, Phone.MESSAGE_CONSTRAINTS); - // while parsing {@code PREFIX_COURSE} alone will reset the COURSEs of the {@code Person} being edited, + // while parsing {@code PREFIX_COURSE} alone will reset the COURSEs of the {@code Student} being edited, // parsing it together with a valid COURSE results in error assertParseFailure(parser, "1" + COURSE_DESC_CS2103T + COURSE_DESC_CS2101 + COURSE_EMPTY, Course.MESSAGE_CONSTRAINTS); @@ -101,11 +101,11 @@ public void parse_invalidValue_failure() { @Test public void parse_allFieldsSpecified_success() { - Index targetIndex = INDEX_SECOND_PERSON; + Index targetIndex = INDEX_SECOND_STUDENT; String userInput = targetIndex.getOneBased() + PHONE_DESC_BOB + COURSE_DESC_CS2101 + EMAIL_DESC_AMY + NAME_DESC_AMY + COURSE_DESC_CS2103T; - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY) + EditStudentDescriptor descriptor = new EditStudentDescriptorBuilder().withName(VALID_NAME_AMY) .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_AMY) .withCourses(VALID_COURSE_CS2101, VALID_COURSE_CS2103T).build(); EditCommand expectedCommand = new EditCommand(targetIndex, descriptor); @@ -115,10 +115,10 @@ public void parse_allFieldsSpecified_success() { @Test public void parse_someFieldsSpecified_success() { - Index targetIndex = INDEX_FIRST_PERSON; + Index targetIndex = INDEX_FIRST_STUDENT; String userInput = targetIndex.getOneBased() + PHONE_DESC_BOB + EMAIL_DESC_AMY; - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withPhone(VALID_PHONE_BOB) + EditStudentDescriptor descriptor = new EditStudentDescriptorBuilder().withPhone(VALID_PHONE_BOB) .withEmail(VALID_EMAIL_AMY).build(); EditCommand expectedCommand = new EditCommand(targetIndex, descriptor); @@ -128,28 +128,28 @@ public void parse_someFieldsSpecified_success() { @Test public void parse_oneFieldSpecified_success() { // name - Index targetIndex = INDEX_THIRD_PERSON; + Index targetIndex = INDEX_THIRD_STUDENT; String userInput = targetIndex.getOneBased() + NAME_DESC_AMY; - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY).build(); + EditStudentDescriptor descriptor = new EditStudentDescriptorBuilder().withName(VALID_NAME_AMY).build(); EditCommand expectedCommand = new EditCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); // phone userInput = targetIndex.getOneBased() + PHONE_DESC_AMY; - descriptor = new EditPersonDescriptorBuilder().withPhone(VALID_PHONE_AMY).build(); + descriptor = new EditStudentDescriptorBuilder().withPhone(VALID_PHONE_AMY).build(); expectedCommand = new EditCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); // email userInput = targetIndex.getOneBased() + EMAIL_DESC_AMY; - descriptor = new EditPersonDescriptorBuilder().withEmail(VALID_EMAIL_AMY).build(); + descriptor = new EditStudentDescriptorBuilder().withEmail(VALID_EMAIL_AMY).build(); expectedCommand = new EditCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); // Courses userInput = targetIndex.getOneBased() + COURSE_DESC_CS2103T; - descriptor = new EditPersonDescriptorBuilder().withCourses(VALID_COURSE_CS2103T).build(); + descriptor = new EditStudentDescriptorBuilder().withCourses(VALID_COURSE_CS2103T).build(); expectedCommand = new EditCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); } @@ -160,7 +160,7 @@ public void parse_multipleRepeatedFields_failure() { // AddCommandParserTest#parse_repeatedNonCOURSEValue_failure() // valid followed by invalid - Index targetIndex = INDEX_FIRST_PERSON; + Index targetIndex = INDEX_FIRST_STUDENT; String userInput = targetIndex.getOneBased() + INVALID_PHONE_DESC + PHONE_DESC_BOB; assertParseFailure(parser, userInput, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE)); @@ -188,10 +188,10 @@ public void parse_multipleRepeatedFields_failure() { @Test public void parse_resetCourses_success() { - Index targetIndex = INDEX_THIRD_PERSON; + Index targetIndex = INDEX_THIRD_STUDENT; String userInput = targetIndex.getOneBased() + COURSE_EMPTY; - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withCourses().build(); + EditStudentDescriptor descriptor = new EditStudentDescriptorBuilder().withCourses().build(); EditCommand expectedCommand = new EditCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); diff --git a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java index 25147310464..bd12305f6a3 100644 --- a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java +++ b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java @@ -4,7 +4,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.logic.parser.ParserUtil.MESSAGE_INVALID_INDEX; import static seedu.address.testutil.Assert.assertThrows; -import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; +import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_STUDENT; import java.util.Arrays; import java.util.Collections; @@ -47,10 +47,10 @@ public void parseIndex_outOfRangeInput_throwsParseException() { @Test public void parseIndex_validInput_success() throws Exception { // No whitespaces - assertEquals(INDEX_FIRST_PERSON, ParserUtil.parseIndex("1")); + assertEquals(INDEX_FIRST_STUDENT, ParserUtil.parseIndex("1")); // Leading and trailing whitespaces - assertEquals(INDEX_FIRST_PERSON, ParserUtil.parseIndex(" 1 ")); + assertEquals(INDEX_FIRST_STUDENT, ParserUtil.parseIndex(" 1 ")); } @Test diff --git a/src/test/java/seedu/address/model/AddressBookTest.java b/src/test/java/seedu/address/model/AddressBookTest.java index 2363b559916..8369721de49 100644 --- a/src/test/java/seedu/address/model/AddressBookTest.java +++ b/src/test/java/seedu/address/model/AddressBookTest.java @@ -18,7 +18,7 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; import seedu.address.model.student.Student; -import seedu.address.model.student.exceptions.DuplicatePersonException; +import seedu.address.model.student.exceptions.DuplicateStudentException; import seedu.address.testutil.StudentBuilder; public class AddressBookTest { @@ -27,7 +27,7 @@ public class AddressBookTest { @Test public void constructor() { - assertEquals(Collections.emptyList(), addressBook.getPersonList()); + assertEquals(Collections.emptyList(), addressBook.getStudentList()); } @Test @@ -43,64 +43,64 @@ public void resetData_withValidReadOnlyAddressBook_replacesData() { } @Test - public void resetData_withDuplicatePersons_throwsDuplicatePersonException() { - // Two persons with the same identity fields + public void resetData_withDuplicateStudents_throwsDuplicateStudentException() { + // Two students with the same identity fields Student editedAlice = new StudentBuilder(ALICE).withCourses(VALID_COURSE_CS2103T) .build(); - List newPersons = Arrays.asList(ALICE, editedAlice); - AddressBookStub newData = new AddressBookStub(newPersons); + List newStudents = Arrays.asList(ALICE, editedAlice); + AddressBookStub newData = new AddressBookStub(newStudents); - assertThrows(DuplicatePersonException.class, () -> addressBook.resetData(newData)); + assertThrows(DuplicateStudentException.class, () -> addressBook.resetData(newData)); } @Test - public void hasPerson_nullPerson_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> addressBook.hasPerson(null)); + public void hasStudent_nullStudent_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> addressBook.hasStudent(null)); } @Test - public void hasPerson_personNotInAddressBook_returnsFalse() { - assertFalse(addressBook.hasPerson(ALICE)); + public void hasStudent_studentNotInAddressBook_returnsFalse() { + assertFalse(addressBook.hasStudent(ALICE)); } @Test - public void hasPerson_personInAddressBook_returnsTrue() { - addressBook.addPerson(ALICE); - assertTrue(addressBook.hasPerson(ALICE)); + public void hasStudent_studentInAddressBook_returnsTrue() { + addressBook.addStudent(ALICE); + assertTrue(addressBook.hasStudent(ALICE)); } @Test - public void hasPerson_personWithSameIdentityFieldsInAddressBook_returnsTrue() { - addressBook.addPerson(ALICE); + public void hasStudent_studentWithSameIdentityFieldsInAddressBook_returnsTrue() { + addressBook.addStudent(ALICE); Student editedAlice = new StudentBuilder(ALICE).withCourses(VALID_COURSE_CS2103T) .build(); - assertTrue(addressBook.hasPerson(editedAlice)); + assertTrue(addressBook.hasStudent(editedAlice)); } @Test - public void getPersonList_modifyList_throwsUnsupportedOperationException() { - assertThrows(UnsupportedOperationException.class, () -> addressBook.getPersonList().remove(0)); + public void getStudentList_modifyList_throwsUnsupportedOperationException() { + assertThrows(UnsupportedOperationException.class, () -> addressBook.getStudentList().remove(0)); } @Test public void toStringMethod() { - String expected = AddressBook.class.getCanonicalName() + "{persons=" + addressBook.getPersonList() + "}"; + String expected = AddressBook.class.getCanonicalName() + "{students=" + addressBook.getStudentList() + "}"; assertEquals(expected, addressBook.toString()); } /** - * A stub ReadOnlyAddressBook whose persons list can violate interface constraints. + * A stub ReadOnlyAddressBook whose students list can violate interface constraints. */ private static class AddressBookStub implements ReadOnlyAddressBook { - private final ObservableList persons = FXCollections.observableArrayList(); + private final ObservableList students = FXCollections.observableArrayList(); - AddressBookStub(Collection persons) { - this.persons.setAll(persons); + AddressBookStub(Collection students) { + this.students.setAll(students); } @Override - public ObservableList getPersonList() { - return persons; + public ObservableList getStudentList() { + return students; } } diff --git a/src/test/java/seedu/address/model/ModelManagerTest.java b/src/test/java/seedu/address/model/ModelManagerTest.java index 6c5b08fa952..466563a3022 100644 --- a/src/test/java/seedu/address/model/ModelManagerTest.java +++ b/src/test/java/seedu/address/model/ModelManagerTest.java @@ -3,7 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; +import static seedu.address.model.Model.PREDICATE_SHOW_ALL_STUDENTS; import static seedu.address.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalStudents.ALICE; import static seedu.address.testutil.TypicalStudents.BENSON; @@ -73,29 +73,29 @@ public void setAddressBookFilePath_validPath_setsAddressBookFilePath() { } @Test - public void hasPerson_nullPerson_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> modelManager.hasPerson(null)); + public void hasStudent_nullStudent_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> modelManager.hasStudent(null)); } @Test - public void hasPerson_personNotInAddressBook_returnsFalse() { - assertFalse(modelManager.hasPerson(ALICE)); + public void hasStudent_studentNotInAddressBook_returnsFalse() { + assertFalse(modelManager.hasStudent(ALICE)); } @Test - public void hasPerson_personInAddressBook_returnsTrue() { - modelManager.addPerson(ALICE); - assertTrue(modelManager.hasPerson(ALICE)); + public void hasStudent_studentInAddressBook_returnsTrue() { + modelManager.addStudent(ALICE); + assertTrue(modelManager.hasStudent(ALICE)); } @Test - public void getFilteredPersonList_modifyList_throwsUnsupportedOperationException() { - assertThrows(UnsupportedOperationException.class, () -> modelManager.getFilteredPersonList().remove(0)); + public void getFilteredStudentList_modifyList_throwsUnsupportedOperationException() { + assertThrows(UnsupportedOperationException.class, () -> modelManager.getFilteredStudentList().remove(0)); } @Test public void equals() { - AddressBook addressBook = new AddressBookBuilder().withPerson(ALICE).withPerson(BENSON).build(); + AddressBook addressBook = new AddressBookBuilder().withStudent(ALICE).withStudent(BENSON).build(); AddressBook differentAddressBook = new AddressBook(); UserPrefs userPrefs = new UserPrefs(); @@ -118,11 +118,11 @@ public void equals() { // different filteredList -> returns false String[] keywords = ALICE.getName().fullName.split("\\s+"); - modelManager.updateFilteredPersonList(new NameContainsKeywordsPredicate(Arrays.asList(keywords))); + modelManager.updateFilteredStudentList(new NameContainsKeywordsPredicate(Arrays.asList(keywords))); assertFalse(modelManager.equals(new ModelManager(addressBook, userPrefs))); // resets modelManager to initial state for upcoming tests - modelManager.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); + modelManager.updateFilteredStudentList(PREDICATE_SHOW_ALL_STUDENTS); // different userPrefs -> returns false UserPrefs differentUserPrefs = new UserPrefs(); diff --git a/src/test/java/seedu/address/model/student/IsStudentOfCoursePredicateTest.java b/src/test/java/seedu/address/model/student/IsStudentOfCoursePredicateTest.java index 99ce730287a..c2ea6913cf4 100644 --- a/src/test/java/seedu/address/model/student/IsStudentOfCoursePredicateTest.java +++ b/src/test/java/seedu/address/model/student/IsStudentOfCoursePredicateTest.java @@ -35,7 +35,7 @@ public void equals() { // null -> returns false assertFalse(firstPredicate.equals(null)); - // different person -> returns false + // different student -> returns false assertFalse(firstPredicate.equals(secondPredicate)); } diff --git a/src/test/java/seedu/address/model/student/NameContainsKeywordsPredicateTest.java b/src/test/java/seedu/address/model/student/NameContainsKeywordsPredicateTest.java index 13150826529..a493c83d51b 100644 --- a/src/test/java/seedu/address/model/student/NameContainsKeywordsPredicateTest.java +++ b/src/test/java/seedu/address/model/student/NameContainsKeywordsPredicateTest.java @@ -35,7 +35,7 @@ public void equals() { // null -> returns false assertFalse(firstPredicate.equals(null)); - // different person -> returns false + // different student -> returns false assertFalse(firstPredicate.equals(secondPredicate)); } diff --git a/src/test/java/seedu/address/model/student/StudentTest.java b/src/test/java/seedu/address/model/student/StudentTest.java index f6123458bfa..d00e3181140 100644 --- a/src/test/java/seedu/address/model/student/StudentTest.java +++ b/src/test/java/seedu/address/model/student/StudentTest.java @@ -20,35 +20,35 @@ public class StudentTest { @Test public void asObservableList_modifyList_throwsUnsupportedOperationException() { - Student person = new StudentBuilder().build(); - assertThrows(UnsupportedOperationException.class, () -> person.getCourses().remove(0)); + Student student = new StudentBuilder().build(); + assertThrows(UnsupportedOperationException.class, () -> student.getCourses().remove(0)); } @Test - public void isSamePerson() { + public void isSameStudent() { // same object -> returns true - assertTrue(ALICE.isSamePerson(ALICE)); + assertTrue(ALICE.isSameStudent(ALICE)); // null -> returns false - assertFalse(ALICE.isSamePerson(null)); + assertFalse(ALICE.isSameStudent(null)); // same name, all other attributes different -> returns true Student editedAlice = new StudentBuilder(ALICE).withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB) .withCourses(VALID_COURSE_CS2103T).build(); - assertTrue(ALICE.isSamePerson(editedAlice)); + assertTrue(ALICE.isSameStudent(editedAlice)); // different name, all other attributes same -> returns false editedAlice = new StudentBuilder(ALICE).withName(VALID_NAME_BOB).build(); - assertFalse(ALICE.isSamePerson(editedAlice)); + assertFalse(ALICE.isSameStudent(editedAlice)); // name differs in case, all other attributes same -> returns false Student editedBob = new StudentBuilder(BOB).withName(VALID_NAME_BOB.toLowerCase()).build(); - assertFalse(BOB.isSamePerson(editedBob)); + assertFalse(BOB.isSameStudent(editedBob)); // name has trailing spaces, all other attributes same -> returns false String nameWithTrailingSpaces = VALID_NAME_BOB + " "; editedBob = new StudentBuilder(BOB).withName(nameWithTrailingSpaces).build(); - assertFalse(BOB.isSamePerson(editedBob)); + assertFalse(BOB.isSameStudent(editedBob)); } @Test @@ -66,7 +66,7 @@ public void equals() { // different type -> returns false assertFalse(ALICE.equals(5)); - // different person -> returns false + // different student -> returns false assertFalse(ALICE.equals(BOB)); // different name -> returns false diff --git a/src/test/java/seedu/address/model/student/UniqueStudentListTest.java b/src/test/java/seedu/address/model/student/UniqueStudentListTest.java index 0038f9c319b..a8283f4aaae 100644 --- a/src/test/java/seedu/address/model/student/UniqueStudentListTest.java +++ b/src/test/java/seedu/address/model/student/UniqueStudentListTest.java @@ -14,161 +14,161 @@ import org.junit.jupiter.api.Test; -import seedu.address.model.student.exceptions.DuplicatePersonException; -import seedu.address.model.student.exceptions.PersonNotFoundException; +import seedu.address.model.student.exceptions.DuplicateStudentException; +import seedu.address.model.student.exceptions.StudentNotFoundException; import seedu.address.testutil.StudentBuilder; public class UniqueStudentListTest { - private final UniquePersonList uniquePersonList = new UniquePersonList(); + private final UniqueStudentList uniqueStudentList = new UniqueStudentList(); @Test - public void contains_nullPerson_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniquePersonList.contains(null)); + public void contains_nullStudent_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> uniqueStudentList.contains(null)); } @Test - public void contains_personNotInList_returnsFalse() { - assertFalse(uniquePersonList.contains(ALICE)); + public void contains_studentNotInList_returnsFalse() { + assertFalse(uniqueStudentList.contains(ALICE)); } @Test - public void contains_personInList_returnsTrue() { - uniquePersonList.add(ALICE); - assertTrue(uniquePersonList.contains(ALICE)); + public void contains_studentInList_returnsTrue() { + uniqueStudentList.add(ALICE); + assertTrue(uniqueStudentList.contains(ALICE)); } @Test - public void contains_personWithSameIdentityFieldsInList_returnsTrue() { - uniquePersonList.add(ALICE); + public void contains_studentWithSameIdentityFieldsInList_returnsTrue() { + uniqueStudentList.add(ALICE); Student editedAlice = new StudentBuilder(ALICE).withCourses(VALID_COURSE_CS2103T) .build(); - assertTrue(uniquePersonList.contains(editedAlice)); + assertTrue(uniqueStudentList.contains(editedAlice)); } @Test - public void add_nullPerson_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniquePersonList.add(null)); + public void add_nullStudent_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> uniqueStudentList.add(null)); } @Test - public void add_duplicatePerson_throwsDuplicatePersonException() { - uniquePersonList.add(ALICE); - assertThrows(DuplicatePersonException.class, () -> uniquePersonList.add(ALICE)); + public void add_duplicateStudent_throwsDuplicateStudentException() { + uniqueStudentList.add(ALICE); + assertThrows(DuplicateStudentException.class, () -> uniqueStudentList.add(ALICE)); } @Test - public void setPerson_nullTargetPerson_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniquePersonList.setPerson(null, ALICE)); + public void setStudent_nullTargetStudent_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> uniqueStudentList.setStudent(null, ALICE)); } @Test - public void setPerson_nullEditedPerson_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniquePersonList.setPerson(ALICE, null)); + public void setStudent_nullEditedStudent_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> uniqueStudentList.setStudent(ALICE, null)); } @Test - public void setPerson_targetPersonNotInList_throwsPersonNotFoundException() { - assertThrows(PersonNotFoundException.class, () -> uniquePersonList.setPerson(ALICE, ALICE)); + public void setStudent_targetStudentNotInList_throwsStudentNotFoundException() { + assertThrows(StudentNotFoundException.class, () -> uniqueStudentList.setStudent(ALICE, ALICE)); } @Test - public void setPerson_editedPersonIsSamePerson_success() { - uniquePersonList.add(ALICE); - uniquePersonList.setPerson(ALICE, ALICE); - UniquePersonList expectedUniquePersonList = new UniquePersonList(); - expectedUniquePersonList.add(ALICE); - assertEquals(expectedUniquePersonList, uniquePersonList); + public void setStudent_editedStudentIsSameStudent_success() { + uniqueStudentList.add(ALICE); + uniqueStudentList.setStudent(ALICE, ALICE); + UniqueStudentList expectedUniqueStudentList = new UniqueStudentList(); + expectedUniqueStudentList.add(ALICE); + assertEquals(expectedUniqueStudentList, uniqueStudentList); } @Test - public void setPerson_editedPersonHasSameIdentity_success() { - uniquePersonList.add(ALICE); + public void setStudent_editedStudentHasSameIdentity_success() { + uniqueStudentList.add(ALICE); Student editedAlice = new StudentBuilder(ALICE).withCourses(VALID_COURSE_CS2103T) .build(); - uniquePersonList.setPerson(ALICE, editedAlice); - UniquePersonList expectedUniquePersonList = new UniquePersonList(); - expectedUniquePersonList.add(editedAlice); - assertEquals(expectedUniquePersonList, uniquePersonList); + uniqueStudentList.setStudent(ALICE, editedAlice); + UniqueStudentList expectedUniqueStudentList = new UniqueStudentList(); + expectedUniqueStudentList.add(editedAlice); + assertEquals(expectedUniqueStudentList, uniqueStudentList); } @Test - public void setPerson_editedPersonHasDifferentIdentity_success() { - uniquePersonList.add(ALICE); - uniquePersonList.setPerson(ALICE, BOB); - UniquePersonList expectedUniquePersonList = new UniquePersonList(); - expectedUniquePersonList.add(BOB); - assertEquals(expectedUniquePersonList, uniquePersonList); + public void setStudent_editedStudentHasDifferentIdentity_success() { + uniqueStudentList.add(ALICE); + uniqueStudentList.setStudent(ALICE, BOB); + UniqueStudentList expectedUniqueStudentList = new UniqueStudentList(); + expectedUniqueStudentList.add(BOB); + assertEquals(expectedUniqueStudentList, uniqueStudentList); } @Test - public void setPerson_editedPersonHasNonUniqueIdentity_throwsDuplicatePersonException() { - uniquePersonList.add(ALICE); - uniquePersonList.add(BOB); - assertThrows(DuplicatePersonException.class, () -> uniquePersonList.setPerson(ALICE, BOB)); + public void setStudent_editedStudentHasNonUniqueIdentity_throwsDuplicateStudentException() { + uniqueStudentList.add(ALICE); + uniqueStudentList.add(BOB); + assertThrows(DuplicateStudentException.class, () -> uniqueStudentList.setStudent(ALICE, BOB)); } @Test - public void remove_nullPerson_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniquePersonList.remove(null)); + public void remove_nullStudent_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> uniqueStudentList.remove(null)); } @Test - public void remove_personDoesNotExist_throwsPersonNotFoundException() { - assertThrows(PersonNotFoundException.class, () -> uniquePersonList.remove(ALICE)); + public void remove_studentDoesNotExist_throwsStudentNotFoundException() { + assertThrows(StudentNotFoundException.class, () -> uniqueStudentList.remove(ALICE)); } @Test - public void remove_existingPerson_removesPerson() { - uniquePersonList.add(ALICE); - uniquePersonList.remove(ALICE); - UniquePersonList expectedUniquePersonList = new UniquePersonList(); - assertEquals(expectedUniquePersonList, uniquePersonList); + public void remove_existingStudent_removesStudent() { + uniqueStudentList.add(ALICE); + uniqueStudentList.remove(ALICE); + UniqueStudentList expectedUniqueStudentList = new UniqueStudentList(); + assertEquals(expectedUniqueStudentList, uniqueStudentList); } @Test - public void setPersons_nullUniquePersonList_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniquePersonList.setPersons((UniquePersonList) null)); + public void setStudents_nullUniqueStudentList_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> uniqueStudentList.setStudents((UniqueStudentList) null)); } @Test - public void setPersons_uniquePersonList_replacesOwnListWithProvidedUniquePersonList() { - uniquePersonList.add(ALICE); - UniquePersonList expectedUniquePersonList = new UniquePersonList(); - expectedUniquePersonList.add(BOB); - uniquePersonList.setPersons(expectedUniquePersonList); - assertEquals(expectedUniquePersonList, uniquePersonList); + public void setStudents_uniqueStudentList_replacesOwnListWithProvidedUniqueStudentList() { + uniqueStudentList.add(ALICE); + UniqueStudentList expectedUniqueStudentList = new UniqueStudentList(); + expectedUniqueStudentList.add(BOB); + uniqueStudentList.setStudents(expectedUniqueStudentList); + assertEquals(expectedUniqueStudentList, uniqueStudentList); } @Test - public void setPersons_nullList_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> uniquePersonList.setPersons((List) null)); + public void setStudents_nullList_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> uniqueStudentList.setStudents((List) null)); } @Test - public void setPersons_list_replacesOwnListWithProvidedList() { - uniquePersonList.add(ALICE); - List personList = Collections.singletonList(BOB); - uniquePersonList.setPersons(personList); - UniquePersonList expectedUniquePersonList = new UniquePersonList(); - expectedUniquePersonList.add(BOB); - assertEquals(expectedUniquePersonList, uniquePersonList); + public void setStudents_list_replacesOwnListWithProvidedList() { + uniqueStudentList.add(ALICE); + List studentList = Collections.singletonList(BOB); + uniqueStudentList.setStudents(studentList); + UniqueStudentList expectedUniqueStudentList = new UniqueStudentList(); + expectedUniqueStudentList.add(BOB); + assertEquals(expectedUniqueStudentList, uniqueStudentList); } @Test - public void setPersons_listWithDuplicatePersons_throwsDuplicatePersonException() { - List listWithDuplicatePersons = Arrays.asList(ALICE, ALICE); - assertThrows(DuplicatePersonException.class, () -> uniquePersonList.setPersons(listWithDuplicatePersons)); + public void setStudents_listWithDuplicateStudents_throwsDuplicateStudentException() { + List listWithDuplicateStudents = Arrays.asList(ALICE, ALICE); + assertThrows(DuplicateStudentException.class, () -> uniqueStudentList.setStudents(listWithDuplicateStudents)); } @Test public void asUnmodifiableObservableList_modifyList_throwsUnsupportedOperationException() { assertThrows(UnsupportedOperationException.class, () - -> uniquePersonList.asUnmodifiableObservableList().remove(0)); + -> uniqueStudentList.asUnmodifiableObservableList().remove(0)); } @Test public void toStringMethod() { - assertEquals(uniquePersonList.asUnmodifiableObservableList().toString(), uniquePersonList.toString()); + assertEquals(uniqueStudentList.asUnmodifiableObservableList().toString(), uniqueStudentList.toString()); } } diff --git a/src/test/java/seedu/address/storage/JsonAdaptedStudentTest.java b/src/test/java/seedu/address/storage/JsonAdaptedStudentTest.java index fafe7db61ca..41dd0ca37c6 100644 --- a/src/test/java/seedu/address/storage/JsonAdaptedStudentTest.java +++ b/src/test/java/seedu/address/storage/JsonAdaptedStudentTest.java @@ -30,66 +30,66 @@ public class JsonAdaptedStudentTest { .collect(Collectors.toList()); @Test - public void toModelType_validPersonDetails_returnsPerson() throws Exception { - JsonAdaptedStudent person = new JsonAdaptedStudent(BENSON); - assertEquals(BENSON, person.toModelType()); + public void toModelType_validStudentDetails_returnsStudent() throws Exception { + JsonAdaptedStudent student = new JsonAdaptedStudent(BENSON); + assertEquals(BENSON, student.toModelType()); } @Test public void toModelType_invalidName_throwsIllegalValueException() { - JsonAdaptedStudent person = + JsonAdaptedStudent student = new JsonAdaptedStudent(INVALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_COURSES); String expectedMessage = Name.MESSAGE_CONSTRAINTS; - assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); + assertThrows(IllegalValueException.class, expectedMessage, student::toModelType); } @Test public void toModelType_nullName_throwsIllegalValueException() { - JsonAdaptedStudent person = new JsonAdaptedStudent(null, VALID_PHONE, VALID_EMAIL, + JsonAdaptedStudent student = new JsonAdaptedStudent(null, VALID_PHONE, VALID_EMAIL, VALID_COURSES); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName()); - assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); + assertThrows(IllegalValueException.class, expectedMessage, student::toModelType); } @Test public void toModelType_invalidPhone_throwsIllegalValueException() { - JsonAdaptedStudent person = + JsonAdaptedStudent student = new JsonAdaptedStudent(VALID_NAME, INVALID_PHONE, VALID_EMAIL, VALID_COURSES); String expectedMessage = Phone.MESSAGE_CONSTRAINTS; - assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); + assertThrows(IllegalValueException.class, expectedMessage, student::toModelType); } @Test public void toModelType_nullPhone_throwsIllegalValueException() { - JsonAdaptedStudent person = new JsonAdaptedStudent(VALID_NAME, null, VALID_EMAIL, + JsonAdaptedStudent student = new JsonAdaptedStudent(VALID_NAME, null, VALID_EMAIL, VALID_COURSES); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Phone.class.getSimpleName()); - assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); + assertThrows(IllegalValueException.class, expectedMessage, student::toModelType); } @Test public void toModelType_invalidEmail_throwsIllegalValueException() { - JsonAdaptedStudent person = + JsonAdaptedStudent student = new JsonAdaptedStudent(VALID_NAME, VALID_PHONE, INVALID_EMAIL, VALID_COURSES); String expectedMessage = Email.MESSAGE_CONSTRAINTS; - assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); + assertThrows(IllegalValueException.class, expectedMessage, student::toModelType); } @Test public void toModelType_nullEmail_throwsIllegalValueException() { - JsonAdaptedStudent person = new JsonAdaptedStudent(VALID_NAME, VALID_PHONE, null, + JsonAdaptedStudent student = new JsonAdaptedStudent(VALID_NAME, VALID_PHONE, null, VALID_COURSES); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Email.class.getSimpleName()); - assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); + assertThrows(IllegalValueException.class, expectedMessage, student::toModelType); } @Test public void toModelType_invalidCourses_throwsIllegalValueException() { List invalidCourses = new ArrayList<>(VALID_COURSES); invalidCourses.add(new JsonAdaptedCourse(INVALID_COURSE)); - JsonAdaptedStudent person = + JsonAdaptedStudent student = new JsonAdaptedStudent(VALID_NAME, VALID_PHONE, VALID_EMAIL, invalidCourses); - assertThrows(IllegalValueException.class, person::toModelType); + assertThrows(IllegalValueException.class, student::toModelType); } } diff --git a/src/test/java/seedu/address/storage/JsonAddressBookStorageTest.java b/src/test/java/seedu/address/storage/JsonAddressBookStorageTest.java index 1bfd7b25a28..3b9376be6d0 100644 --- a/src/test/java/seedu/address/storage/JsonAddressBookStorageTest.java +++ b/src/test/java/seedu/address/storage/JsonAddressBookStorageTest.java @@ -51,13 +51,13 @@ public void read_notJsonFormat_exceptionThrown() { } @Test - public void readAddressBook_invalidPersonAddressBook_throwDataLoadingException() { - assertThrows(DataLoadingException.class, () -> readAddressBook("invalidPersonAddressBook.json")); + public void readAddressBook_invalidStudentAddressBook_throwDataLoadingException() { + assertThrows(DataLoadingException.class, () -> readAddressBook("invalidStudentAddressBook.json")); } @Test - public void readAddressBook_invalidAndValidPersonAddressBook_throwDataLoadingException() { - assertThrows(DataLoadingException.class, () -> readAddressBook("invalidAndValidPersonAddressBook.json")); + public void readAddressBook_invalidAndValidStudentAddressBook_throwDataLoadingException() { + assertThrows(DataLoadingException.class, () -> readAddressBook("invalidAndValidStudentAddressBook.json")); } @Test @@ -72,14 +72,14 @@ public void readAndSaveAddressBook_allInOrder_success() throws Exception { assertEquals(original, new AddressBook(readBack)); // Modify data, overwrite exiting file, and read back - original.addPerson(HOON); - original.removePerson(ALICE); + original.addStudent(HOON); + original.removeStudent(ALICE); jsonAddressBookStorage.saveAddressBook(original, filePath); readBack = jsonAddressBookStorage.readAddressBook(filePath).get(); assertEquals(original, new AddressBook(readBack)); // Save and read without specifying file path - original.addPerson(IDA); + original.addStudent(IDA); jsonAddressBookStorage.saveAddressBook(original); // file path not specified readBack = jsonAddressBookStorage.readAddressBook().get(); // file path not specified assertEquals(original, new AddressBook(readBack)); diff --git a/src/test/java/seedu/address/storage/JsonSerializableAddressBookTest.java b/src/test/java/seedu/address/storage/JsonSerializableAddressBookTest.java index a243bc31d43..642d7cd7f9b 100644 --- a/src/test/java/seedu/address/storage/JsonSerializableAddressBookTest.java +++ b/src/test/java/seedu/address/storage/JsonSerializableAddressBookTest.java @@ -16,31 +16,31 @@ public class JsonSerializableAddressBookTest { private static final Path TEST_DATA_FOLDER = Paths.get("src", "test", "data", "JsonSerializableAddressBookTest"); - private static final Path TYPICAL_PERSONS_FILE = TEST_DATA_FOLDER.resolve("typicalStudentsAddressBook.json"); - private static final Path INVALID_PERSON_FILE = TEST_DATA_FOLDER.resolve("invalidStudentAddressBook.json"); - private static final Path DUPLICATE_PERSON_FILE = TEST_DATA_FOLDER.resolve("duplicateStudentAddressBook.json"); + private static final Path TYPICAL_STUDENTS_FILE = TEST_DATA_FOLDER.resolve("typicalStudentsAddressBook.json"); + private static final Path INVALID_STUDENT_FILE = TEST_DATA_FOLDER.resolve("invalidStudentAddressBook.json"); + private static final Path DUPLICATE_STUDENT_FILE = TEST_DATA_FOLDER.resolve("duplicateStudentAddressBook.json"); @Test - public void toModelType_typicalPersonsFile_success() throws Exception { - JsonSerializableAddressBook dataFromFile = JsonUtil.readJsonFile(TYPICAL_PERSONS_FILE, + public void toModelType_typicalStudentsFile_success() throws Exception { + JsonSerializableAddressBook dataFromFile = JsonUtil.readJsonFile(TYPICAL_STUDENTS_FILE, JsonSerializableAddressBook.class).get(); AddressBook addressBookFromFile = dataFromFile.toModelType(); - AddressBook typicalPersonsAddressBook = TypicalStudents.getTypicalAddressBook(); - assertEquals(addressBookFromFile, typicalPersonsAddressBook); + AddressBook typicalStudentsAddressBook = TypicalStudents.getTypicalAddressBook(); + assertEquals(addressBookFromFile, typicalStudentsAddressBook); } @Test - public void toModelType_invalidPersonFile_throwsIllegalValueException() throws Exception { - JsonSerializableAddressBook dataFromFile = JsonUtil.readJsonFile(INVALID_PERSON_FILE, + public void toModelType_invalidStudentFile_throwsIllegalValueException() throws Exception { + JsonSerializableAddressBook dataFromFile = JsonUtil.readJsonFile(INVALID_STUDENT_FILE, JsonSerializableAddressBook.class).get(); assertThrows(IllegalValueException.class, dataFromFile::toModelType); } @Test - public void toModelType_duplicatePersons_throwsIllegalValueException() throws Exception { - JsonSerializableAddressBook dataFromFile = JsonUtil.readJsonFile(DUPLICATE_PERSON_FILE, + public void toModelType_duplicateStudents_throwsIllegalValueException() throws Exception { + JsonSerializableAddressBook dataFromFile = JsonUtil.readJsonFile(DUPLICATE_STUDENT_FILE, JsonSerializableAddressBook.class).get(); - assertThrows(IllegalValueException.class, JsonSerializableAddressBook.MESSAGE_DUPLICATE_PERSON, + assertThrows(IllegalValueException.class, JsonSerializableAddressBook.MESSAGE_DUPLICATE_STUDENT, dataFromFile::toModelType); } diff --git a/src/test/java/seedu/address/testutil/AddressBookBuilder.java b/src/test/java/seedu/address/testutil/AddressBookBuilder.java index f07345e90cf..2005c4d3f42 100644 --- a/src/test/java/seedu/address/testutil/AddressBookBuilder.java +++ b/src/test/java/seedu/address/testutil/AddressBookBuilder.java @@ -6,7 +6,7 @@ /** * A utility class to help with building Addressbook objects. * Example usage:
- * {@code AddressBook ab = new AddressBookBuilder().withPerson("John", "Doe").build();} + * {@code AddressBook ab = new AddressBookBuilder().withStudent("John", "Doe").build();} */ public class AddressBookBuilder { @@ -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 Student} to the {@code AddressBook} that we are building. */ - public AddressBookBuilder withPerson(Student person) { - addressBook.addPerson(person); + public AddressBookBuilder withStudent(Student student) { + addressBook.addStudent(student); return this; } diff --git a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java deleted file mode 100644 index c09246a342c..00000000000 --- a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java +++ /dev/null @@ -1,77 +0,0 @@ -package seedu.address.testutil; - -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; -import seedu.address.model.course.Course; -import seedu.address.model.student.Email; -import seedu.address.model.student.Name; -import seedu.address.model.student.Phone; -import seedu.address.model.student.Student; - -/** - * A utility class to help with building EditPersonDescriptor objects. - */ -public class EditPersonDescriptorBuilder { - - private EditPersonDescriptor descriptor; - - public EditPersonDescriptorBuilder() { - descriptor = new EditPersonDescriptor(); - } - - public EditPersonDescriptorBuilder(EditPersonDescriptor descriptor) { - this.descriptor = new EditPersonDescriptor(descriptor); - } - - /** - * Returns an {@code EditPersonDescriptor} with fields containing {@code person}'s details - */ - public EditPersonDescriptorBuilder(Student person) { - descriptor = new EditPersonDescriptor(); - descriptor.setName(person.getName()); - descriptor.setPhone(person.getPhone()); - descriptor.setEmail(person.getEmail()); - descriptor.setCourses(person.getCourses()); - } - - /** - * Sets the {@code Name} of the {@code EditPersonDescriptor} that we are building. - */ - public EditPersonDescriptorBuilder withName(String name) { - descriptor.setName(new Name(name)); - return this; - } - - /** - * Sets the {@code Phone} of the {@code EditPersonDescriptor} that we are building. - */ - public EditPersonDescriptorBuilder withPhone(String phone) { - descriptor.setPhone(new Phone(phone)); - return this; - } - - /** - * Sets the {@code Email} of the {@code EditPersonDescriptor} that we are building. - */ - public EditPersonDescriptorBuilder withEmail(String email) { - descriptor.setEmail(new Email(email)); - return this; - } - - /** - * Parses the {@code course} into a {@code Set} and set it to the {@code EditPersonDescriptor} - * that we are building. - */ - public EditPersonDescriptorBuilder withCourses(String... courses) { - Set courseSet = Stream.of(courses).map(Course::new).collect(Collectors.toSet()); - descriptor.setCourses(courseSet); - return this; - } - - public EditPersonDescriptor build() { - return descriptor; - } -} diff --git a/src/test/java/seedu/address/testutil/EditStudentDescriptorBuilder.java b/src/test/java/seedu/address/testutil/EditStudentDescriptorBuilder.java new file mode 100644 index 00000000000..6e2237d4eb7 --- /dev/null +++ b/src/test/java/seedu/address/testutil/EditStudentDescriptorBuilder.java @@ -0,0 +1,77 @@ +package seedu.address.testutil; + +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import seedu.address.logic.commands.EditCommand.EditStudentDescriptor; +import seedu.address.model.course.Course; +import seedu.address.model.student.Email; +import seedu.address.model.student.Name; +import seedu.address.model.student.Phone; +import seedu.address.model.student.Student; + +/** + * A utility class to help with building EditStudentDescriptor objects. + */ +public class EditStudentDescriptorBuilder { + + private EditStudentDescriptor descriptor; + + public EditStudentDescriptorBuilder() { + descriptor = new EditStudentDescriptor(); + } + + public EditStudentDescriptorBuilder(EditStudentDescriptor descriptor) { + this.descriptor = new EditStudentDescriptor(descriptor); + } + + /** + * Returns an {@code EditStudentDescriptor} with fields containing {@code student}'s details + */ + public EditStudentDescriptorBuilder(Student student) { + descriptor = new EditStudentDescriptor(); + descriptor.setName(student.getName()); + descriptor.setPhone(student.getPhone()); + descriptor.setEmail(student.getEmail()); + descriptor.setCourses(student.getCourses()); + } + + /** + * Sets the {@code Name} of the {@code EditStudentDescriptor} that we are building. + */ + public EditStudentDescriptorBuilder withName(String name) { + descriptor.setName(new Name(name)); + return this; + } + + /** + * Sets the {@code Phone} of the {@code EditStudentDescriptor} that we are building. + */ + public EditStudentDescriptorBuilder withPhone(String phone) { + descriptor.setPhone(new Phone(phone)); + return this; + } + + /** + * Sets the {@code Email} of the {@code EditStudentDescriptor} that we are building. + */ + public EditStudentDescriptorBuilder withEmail(String email) { + descriptor.setEmail(new Email(email)); + return this; + } + + /** + * Parses the {@code course} into a {@code Set} and set it to the {@code EditStudentDescriptor} + * that we are building. + */ + public EditStudentDescriptorBuilder withCourses(String... courses) { + Set courseSet = Stream.of(courses).map(Course::new).collect(Collectors.toSet()); + descriptor.setCourses(courseSet); + return this; + } + + public EditStudentDescriptor build() { + return descriptor; + } +} diff --git a/src/test/java/seedu/address/testutil/StudentBuilder.java b/src/test/java/seedu/address/testutil/StudentBuilder.java index a4c7d05bc35..c2ffcee2b2d 100644 --- a/src/test/java/seedu/address/testutil/StudentBuilder.java +++ b/src/test/java/seedu/address/testutil/StudentBuilder.java @@ -11,7 +11,7 @@ import seedu.address.model.util.SampleDataUtil; /** - * A utility class to help with building Person objects. + * A utility class to help with building Student objects. */ public class StudentBuilder { @@ -25,7 +25,7 @@ public class StudentBuilder { private Set courses; /** - * Creates a {@code PersonBuilder} with the default details. + * Creates a {@code StudentBuilder} with the default details. */ public StudentBuilder() { name = new Name(DEFAULT_NAME); @@ -35,17 +35,17 @@ public StudentBuilder() { } /** - * Initializes the PersonBuilder with the data of {@code personToCopy}. + * Initializes the StudentBuilder with the data of {@code studentToCopy}. */ - public StudentBuilder(Student personToCopy) { - name = personToCopy.getName(); - phone = personToCopy.getPhone(); - email = personToCopy.getEmail(); - courses = new HashSet<>(personToCopy.getCourses()); + public StudentBuilder(Student studentToCopy) { + name = studentToCopy.getName(); + phone = studentToCopy.getPhone(); + email = studentToCopy.getEmail(); + courses = new HashSet<>(studentToCopy.getCourses()); } /** - * Sets the {@code Name} of the {@code Person} that we are building. + * Sets the {@code Name} of the {@code Student} that we are building. */ public StudentBuilder withName(String name) { this.name = new Name(name); @@ -53,7 +53,7 @@ public StudentBuilder withName(String name) { } /** - * Sets the {@code Phone} of the {@code Person} that we are building. + * Sets the {@code Phone} of the {@code Student} that we are building. */ public StudentBuilder withPhone(String phone) { this.phone = new Phone(phone); @@ -61,7 +61,7 @@ public StudentBuilder withPhone(String phone) { } /** - * Sets the {@code Email} of the {@code Person} that we are building. + * Sets the {@code Email} of the {@code Student} that we are building. */ public StudentBuilder withEmail(String email) { this.email = new Email(email); @@ -69,7 +69,7 @@ public StudentBuilder withEmail(String email) { } /** - * Parses the {@code courses} into a {@code Set} and set it to the {@code Person} that we are building. + * Parses the {@code courses} into a {@code Set} and set it to the {@code Student} that we are building. */ public StudentBuilder withCourses(String ... courses) { this.courses = SampleDataUtil.getCourseSet(courses); diff --git a/src/test/java/seedu/address/testutil/StudentUtil.java b/src/test/java/seedu/address/testutil/StudentUtil.java index 68954b2f760..67b980871a4 100644 --- a/src/test/java/seedu/address/testutil/StudentUtil.java +++ b/src/test/java/seedu/address/testutil/StudentUtil.java @@ -8,40 +8,40 @@ import java.util.Set; import seedu.address.logic.commands.AddCommand; -import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; +import seedu.address.logic.commands.EditCommand.EditStudentDescriptor; import seedu.address.model.course.Course; import seedu.address.model.student.Student; /** - * A utility class for Person. + * A utility class for Student. */ public class StudentUtil { /** - * Returns an add command string for adding the {@code person}. + * Returns an add command string for adding the {@code student}. */ - public static String getAddCommand(Student person) { - return AddCommand.COMMAND_WORD + " " + getPersonDetails(person); + public static String getAddCommand(Student student) { + return AddCommand.COMMAND_WORD + " " + getStudentDetails(student); } /** - * Returns the part of command string for the given {@code person}'s details. + * Returns the part of command string for the given {@code student}'s details. */ - public static String getPersonDetails(Student person) { + public static String getStudentDetails(Student student) { 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 + " "); - person.getCourses().stream().forEach( + sb.append(PREFIX_NAME + student.getName().fullName + " "); + sb.append(PREFIX_PHONE + student.getPhone().value + " "); + sb.append(PREFIX_EMAIL + student.getEmail().value + " "); + student.getCourses().stream().forEach( s -> sb.append(PREFIX_COURSE + s.courseCode + " ") ); return sb.toString(); } /** - * Returns the part of command string for the given {@code EditPersonDescriptor}'s details. + * Returns the part of command string for the given {@code EditStudentDescriptor}'s details. */ - public static String getEditPersonDescriptorDetails(EditPersonDescriptor descriptor) { + public static String getEditStudentDescriptorDetails(EditStudentDescriptor descriptor) { StringBuilder sb = new StringBuilder(); descriptor.getName().ifPresent(name -> sb.append(PREFIX_NAME).append(name.fullName).append(" ")); descriptor.getPhone().ifPresent(phone -> sb.append(PREFIX_PHONE).append(phone.value).append(" ")); diff --git a/src/test/java/seedu/address/testutil/TestUtil.java b/src/test/java/seedu/address/testutil/TestUtil.java index 0462c8baf54..d9aac87d8c6 100644 --- a/src/test/java/seedu/address/testutil/TestUtil.java +++ b/src/test/java/seedu/address/testutil/TestUtil.java @@ -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 student in the {@code model}'s student list. */ public static Index getMidIndex(Model model) { - return Index.fromOneBased(model.getFilteredPersonList().size() / 2); + return Index.fromOneBased(model.getFilteredStudentList().size() / 2); } /** - * Returns the last index of the person in the {@code model}'s person list. + * Returns the last index of the student in the {@code model}'s student list. */ public static Index getLastIndex(Model model) { - return Index.fromOneBased(model.getFilteredPersonList().size()); + return Index.fromOneBased(model.getFilteredStudentList().size()); } /** - * Returns the person in the {@code model}'s person list at {@code index}. + * Returns the student in the {@code model}'s student list at {@code index}. */ - public static Student getPerson(Model model, Index index) { - return model.getFilteredPersonList().get(index.getZeroBased()); + public static Student getStudent(Model model, Index index) { + return model.getFilteredStudentList().get(index.getZeroBased()); } } diff --git a/src/test/java/seedu/address/testutil/TypicalIndexes.java b/src/test/java/seedu/address/testutil/TypicalIndexes.java index 1e613937657..cfa8cf8b11c 100644 --- a/src/test/java/seedu/address/testutil/TypicalIndexes.java +++ b/src/test/java/seedu/address/testutil/TypicalIndexes.java @@ -6,7 +6,7 @@ * A utility class containing a list of {@code Index} objects to be used in tests. */ public class TypicalIndexes { - public static final Index INDEX_FIRST_PERSON = Index.fromOneBased(1); - public static final Index INDEX_SECOND_PERSON = Index.fromOneBased(2); - public static final Index INDEX_THIRD_PERSON = Index.fromOneBased(3); + public static final Index INDEX_FIRST_STUDENT = Index.fromOneBased(1); + public static final Index INDEX_SECOND_STUDENT = Index.fromOneBased(2); + public static final Index INDEX_THIRD_STUDENT = Index.fromOneBased(3); } diff --git a/src/test/java/seedu/address/testutil/TypicalStudents.java b/src/test/java/seedu/address/testutil/TypicalStudents.java index 0c254d82396..0b2b5d573f1 100644 --- a/src/test/java/seedu/address/testutil/TypicalStudents.java +++ b/src/test/java/seedu/address/testutil/TypicalStudents.java @@ -17,7 +17,7 @@ import seedu.address.model.student.Student; /** - * A utility class containing a list of {@code Person} objects to be used in tests. + * A utility class containing a list of {@code Student} objects to be used in tests. */ public class TypicalStudents { @@ -45,7 +45,7 @@ public class TypicalStudents { public static final Student IDA = new StudentBuilder().withName("Ida Mueller").withPhone("8482131") .withEmail("hans@example.com").build(); - // Manually added - Person's details found in {@code CommandTestUtil} + // Manually added - Student's details found in {@code CommandTestUtil} public static final Student AMY = new StudentBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) .withEmail(VALID_EMAIL_AMY).withCourses(VALID_COURSE_CS2103T).build(); public static final Student BOB = new StudentBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) @@ -57,17 +57,17 @@ public class TypicalStudents { private TypicalStudents() {} // prevents instantiation /** - * Returns an {@code AddressBook} with all the typical persons. + * Returns an {@code AddressBook} with all the typical students. */ public static AddressBook getTypicalAddressBook() { AddressBook ab = new AddressBook(); - for (Student person : getTypicalPersons()) { - ab.addPerson(person); + for (Student student : getTypicalStudents()) { + ab.addStudent(student); } return ab; } - public static List getTypicalPersons() { + public static List getTypicalStudents() { return new ArrayList<>(Arrays.asList(ALICE, BENSON, CARL, DANIEL, ELLE, FIONA, GEORGE)); } }