forked from CS2113-AY1819S2-T08-3/main
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #24 from seanieyap/develop
Add separate classes to aid in development.
- Loading branch information
Showing
30 changed files
with
975 additions
and
224 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package planmysem.commands; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import planmysem.common.Utils; | ||
import planmysem.data.exception.IllegalValueException; | ||
import planmysem.data.slot.Description; | ||
import planmysem.data.slot.Location; | ||
import planmysem.data.slot.Name; | ||
import planmysem.data.slot.ReadOnlySlot; | ||
import planmysem.data.slot.Slot; | ||
import planmysem.data.tag.Tag; | ||
|
||
/** | ||
* Adds a person to the address book. | ||
*/ | ||
public class AddCommandP extends CommandP { | ||
|
||
public static final String COMMAND_WORD = "add"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD + ":\n" + "Adds a slot to the Planner. " | ||
+ "Contact details can be marked private by prepending 'p' to the prefix.\n\t" | ||
+ "Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]...\n\t" | ||
+ "Example: " + COMMAND_WORD | ||
+ " John Doe p/98765432 e/[email protected] a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney"; | ||
|
||
public static final String MESSAGE_SUCCESS = "New slot added: %1$s"; | ||
// public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book"; | ||
|
||
private final Slot slot; | ||
|
||
/** | ||
* Convenience constructor using raw values. | ||
* | ||
* @throws IllegalValueException if any of the raw values are invalid | ||
*/ | ||
public AddCommandP(String name, String location, String description, String startTime, | ||
int duration, Set<String> tags) throws IllegalValueException { | ||
final Set<Tag> tagSet = new HashSet<>(); | ||
|
||
for (String tagName : tags) { | ||
tagSet.add(new Tag(tagName)); | ||
} | ||
|
||
this.slot = new Slot(new Name(name), new Location(location), new Description(description), | ||
Utils.getLocalTime(startTime), duration, tagSet); | ||
} | ||
|
||
public AddCommandP(Slot slot) { | ||
this.slot = slot; | ||
} | ||
public ReadOnlySlot getSlot() { | ||
return slot; | ||
} | ||
|
||
@Override | ||
public CommandResultP execute() { | ||
// try { | ||
planner.addSlot(slot); | ||
return new CommandResultP(String.format(MESSAGE_SUCCESS, slot)); | ||
// } catch (UniquePersonList.DuplicatePersonException dpe) { | ||
// return new CommandResult(MESSAGE_DUPLICATE_PERSON); | ||
// } | ||
} | ||
|
||
} |
Oops, something went wrong.