forked from nus-cs2103-AY1819S2/addressbook-level4
-
Notifications
You must be signed in to change notification settings - Fork 4
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 #4 from CS2103-AY1819S2-W17-2/master
Update v1.2
- Loading branch information
Showing
41 changed files
with
1,032 additions
and
279 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,16 +4,20 @@ | |
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_NAME; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_NRIC; | ||
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_YEAR; | ||
|
||
import seedu.address.logic.CommandHistory; | ||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.patient.Patient; | ||
import seedu.address.model.patient.exceptions.PersonIsNotPatient; | ||
import seedu.address.model.person.Person; | ||
|
||
/** | ||
* Adds a person to the address book. | ||
* Adds a patient to the address book. | ||
*/ | ||
public class AddCommand extends Command { | ||
|
||
|
@@ -22,29 +26,47 @@ public class AddCommand extends Command { | |
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to the address book. " | ||
+ "Parameters: " | ||
+ PREFIX_NAME + "NAME " | ||
+ PREFIX_NRIC + "NRIC " | ||
+ PREFIX_YEAR + "DOB " | ||
+ PREFIX_PHONE + "PHONE " | ||
+ PREFIX_EMAIL + "EMAIL " | ||
+ PREFIX_ADDRESS + "ADDRESS " | ||
+ "[" + PREFIX_TAG + "TAG]...\n" | ||
+ "Example: " + COMMAND_WORD + " " | ||
+ PREFIX_NAME + "John Doe " | ||
+ PREFIX_NRIC + "S1234567A " | ||
+ PREFIX_YEAR + "30-12-1990 " | ||
+ PREFIX_PHONE + "98765432 " | ||
+ PREFIX_EMAIL + "[email protected] " | ||
+ PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 " | ||
+ PREFIX_TAG + "friends " | ||
+ PREFIX_TAG + "owesMoney"; | ||
|
||
public static final String MESSAGE_SUCCESS = "New person added: %1$s"; | ||
public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book"; | ||
public static final String MESSAGE_SUCCESS = "New patient added: %1$s"; | ||
public static final String MESSAGE_DUPLICATE_PERSON = "This patient already exists in the dental book"; | ||
|
||
private final Person toAdd; | ||
private final Patient toAdd; | ||
|
||
/** | ||
* Creates an AddCommand to add the specified {@code Patient} | ||
* @param patient the patient to be added. | ||
*/ | ||
public AddCommand(Patient patient) { | ||
requireNonNull(patient); | ||
toAdd = patient; | ||
} | ||
|
||
/** | ||
* Creates an AddCommand to add the specified {@code Person} | ||
* @param person the person to be added. | ||
*/ | ||
public AddCommand(Person person) { | ||
requireNonNull(person); | ||
toAdd = person; | ||
if (person instanceof Patient) { | ||
toAdd = (Patient) person; | ||
} else { | ||
throw new PersonIsNotPatient(); | ||
} | ||
} | ||
|
||
@Override | ||
|
@@ -57,7 +79,7 @@ public CommandResult execute(Model model, CommandHistory history) throws Command | |
|
||
model.addPerson(toAdd); | ||
model.commitAddressBook(); | ||
return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd)); | ||
return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd.getName())); | ||
} | ||
|
||
@Override | ||
|
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
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
Oops, something went wrong.