forked from nus-cs2103-AY1718S2/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.
- Loading branch information
Showing
13 changed files
with
525 additions
and
27 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
40 changes: 40 additions & 0 deletions
40
src/main/java/seedu/address/logic/commands/SeekRaCommand.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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import seedu.address.model.person.UnitNumberContainsKeywordsPredicate; | ||
|
||
/** | ||
* Finds and lists the Resident Assistant (RA) of an individual RC Student | ||
* in address book whose name contains any of the argument keywords. | ||
* Keyword matching is case sensitive. | ||
*/ | ||
public class SeekRaCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "seek"; | ||
|
||
public static final String COMMAND_ALIAS = "sk"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD | ||
+ ": Seeks the Resident Assistant (RA) of an individual RC student whose name contain any of " | ||
+ "the specified keywords (case-sensitive) and displays them as a list with index numbers.\n" | ||
+ "Parameters: KEYWORD [MORE_KEYWORDS]...\n" | ||
+ "Example: " + COMMAND_WORD + " alice bob charlie"; | ||
|
||
private final UnitNumberContainsKeywordsPredicate predicate; | ||
|
||
public SeekRaCommand(UnitNumberContainsKeywordsPredicate predicate) { | ||
this.predicate = predicate; | ||
} | ||
|
||
@Override | ||
public CommandResult execute() { | ||
model.updateFilteredPersonList(predicate); | ||
return new CommandResult(getMessageForRaShownSummary(model.getFilteredPersonList().size())); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
return other == this // short circuit if same object | ||
|| (other instanceof SeekRaCommand // instanceof handles nulls | ||
&& this.predicate.equals(((SeekRaCommand) other).predicate)); // state check | ||
} | ||
} |
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
36 changes: 36 additions & 0 deletions
36
src/main/java/seedu/address/logic/parser/SeekRaCommandParser.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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package seedu.address.logic.parser; | ||
|
||
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; | ||
|
||
import java.util.Arrays; | ||
|
||
import seedu.address.logic.commands.SeekRaCommand; | ||
import seedu.address.logic.parser.exceptions.ParseException; | ||
import seedu.address.model.person.UnitNumberContainsKeywordsPredicate; | ||
|
||
/** | ||
* Parses input arguments and creates a new SeekRaCommand object | ||
*/ | ||
public class SeekRaCommandParser implements Parser<SeekRaCommand> { | ||
|
||
/** | ||
* Parses the given {@code String} of arguments in the context of the SeekRaCommand | ||
* and returns an SeekRaCommand object for execution. | ||
* @throws ParseException if the user input does not conform the expected format | ||
*/ | ||
public SeekRaCommand parse(String args) throws ParseException { | ||
|
||
String trimmedArgs = args.trim(); | ||
if (trimmedArgs.isEmpty()) { | ||
throw new ParseException( | ||
String.format(MESSAGE_INVALID_COMMAND_FORMAT, SeekRaCommand.MESSAGE_USAGE)); | ||
} | ||
|
||
trimmedArgs = trimmedArgs + " " + "RA"; | ||
|
||
String[] nameKeywords = (trimmedArgs.split("\\s+")); | ||
|
||
return new SeekRaCommand(new UnitNumberContainsKeywordsPredicate(Arrays.asList(nameKeywords))); | ||
} | ||
|
||
} |
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.