forked from nus-cs2103-AY2425S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from jian7490/person-to-student
Adapt class Person to Student to fit with TAchy's model design
- Loading branch information
Showing
97 changed files
with
1,509 additions
and
1,828 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,75 +75,75 @@ 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]…` | ||
|
||
<box type="tip" seamless> | ||
|
||
**Tip:** A person can have any number of tags (including 0) | ||
**Tip:** A student can have any number of tags (including 0) | ||
</box> | ||
|
||
Examples: | ||
* `add n/John Doe p/98765432 e/[email protected] a/John street, block 123, #01-01` | ||
* `add n/Betsy Crowe t/friend e/[email protected] 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/[email protected]` Edits the phone number and email address of the 1st person to be `91234567` and `[email protected]` 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/[email protected]` Edits the phone number and email address of the 1st student to be `91234567` and `[email protected]` 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]` | ||
|
||
* The search is case-insensitive. e.g `hans` will match `Hans` | ||
* 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: | ||
* `find John` returns `john` and `John Doe` | ||
* `find alex david` returns `Alex Yeoh`, `David Li`<br> | ||
![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 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, … | ||
|
||
Examples: | ||
* `list` followed by `delete 2` deletes the 2nd person in the address book. | ||
* `find Betsy` followed by `delete 1` deletes the 1st person in the results of the `find` command. | ||
* `list` followed by `delete 2` deletes the 2nd student in the address book. | ||
* `find Betsy` followed by `delete 1` deletes the 1st student in the results of the `find` command. | ||
|
||
### Clearing all entries : `clear` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 15 additions & 18 deletions
33
src/main/java/seedu/address/logic/commands/AddCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,63 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_GRADE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_SUBJECT; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_GRADE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; | ||
|
||
import seedu.address.commons.util.ToStringBuilder; | ||
import seedu.address.logic.Messages; | ||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.person.Person; | ||
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_student"; | ||
|
||
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 " | ||
+ PREFIX_EMAIL + "EMAIL " | ||
+ PREFIX_ADDRESS + "ADDRESS " | ||
+ "[" + PREFIX_TAG + "TAG]...\n" | ||
+ "Example: " + COMMAND_WORD + " " | ||
+ PREFIX_NAME + "John Doe " | ||
+ PREFIX_PHONE + "98765432 " | ||
+ PREFIX_EMAIL + "[email protected] " | ||
+ PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 " | ||
+ PREFIX_TAG + "friends " | ||
+ PREFIX_TAG + "owesMoney" | ||
+ PREFIX_SUBJECT + "MATH" | ||
+ PREFIX_GRADE + "P6"; | ||
|
||
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 Person toAdd; | ||
private final Student toAdd; | ||
|
||
/** | ||
* Creates an AddCommand to add the specified {@code Person} | ||
* Creates an AddCommand to add the specified {@code Student} | ||
*/ | ||
public AddCommand(Person 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))); | ||
} | ||
|
||
|
Oops, something went wrong.