forked from AY2324S1-CS2113T-W11-2/tp
-
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.
- Loading branch information
Showing
14 changed files
with
181 additions
and
34 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 |
---|---|---|
|
@@ -43,4 +43,5 @@ checkstyle { | |
|
||
run{ | ||
standardInput = System.in | ||
enableAssertions = true | ||
} |
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 |
---|---|---|
@@ -1,12 +1,42 @@ | ||
package seedu.wildwatch.command; | ||
|
||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
import seedu.wildwatch.entry.EntryList; | ||
import seedu.wildwatch.exception.IncorrectInputException; | ||
import seedu.wildwatch.operation.Ui; | ||
|
||
/** | ||
* Command class for listing all task in EntryList | ||
* Command class for adding task to EntryList | ||
*/ | ||
public class AddCommand extends Command { | ||
public static void addEntry(String inputBuffer, boolean isFromFile) { | ||
//Todo Split input into Date, Species, Remark | ||
//Todo Insert into EntryList | ||
|
||
public static final Pattern ADD_ENTRY_COMMAND_FORMAT = | ||
Pattern.compile("add" | ||
+ " D/(?<date>[^/]+)" | ||
+ " S/(?<species>[^/]+)" | ||
+ " N/(?<name>[^/]+)" | ||
+ "(?: R/(?<remark>[^/]+))?"); | ||
|
||
public static void addEntry(String inputBuffer, boolean isFromFile) throws IncorrectInputException { | ||
//if (!isFromFile) { | ||
// Ui.listMessagePrinter(); | ||
//} | ||
|
||
final Matcher matcher = ADD_ENTRY_COMMAND_FORMAT.matcher(inputBuffer); | ||
if (!matcher.matches()) { | ||
throw new IncorrectInputException(); | ||
} | ||
|
||
final String date = matcher.group("date"); | ||
final String species = matcher.group("species"); | ||
final String name = matcher.group("name"); | ||
final String remark = matcher.group("remark"); | ||
|
||
EntryList.addEntry(date, species, name, remark); | ||
Ui.entryAddedMessagePrinter(); | ||
Ui.printEntry(EntryList.getArraySize() - 1); | ||
} | ||
} | ||
|
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
4 changes: 4 additions & 0 deletions
4
src/main/java/seedu/wildwatch/exception/IncorrectInputException.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,4 @@ | ||
package seedu.wildwatch.exception; | ||
|
||
public class IncorrectInputException extends Exception { | ||
} |
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.