Skip to content

Commit

Permalink
Rectify spelling errors in SummaryCommandParser
Browse files Browse the repository at this point in the history
  • Loading branch information
woodenclock committed Nov 9, 2023
1 parent 8abe0b3 commit 80bbd7e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
32 changes: 32 additions & 0 deletions WildWatch.log.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
11월 10, 2023 12:00:38 오전 seedu.wildwatch.execute.InputHandler handleInput
INFO: Input received: summary
11월 10, 2023 12:00:38 오전 seedu.wildwatch.execute.Router route
INFO: Routing entry for input: summary
11월 10, 2023 12:00:38 오전 seedu.wildwatch.execute.Router route
INFO: Summary command was input: summary
11월 10, 2023 12:00:45 오전 seedu.wildwatch.execute.InputHandler handleInput
INFO: Input received: summary White Rhinoceros
11월 10, 2023 12:00:45 오전 seedu.wildwatch.execute.Router route
INFO: Routing entry for input: summary White Rhinoceros
11월 10, 2023 12:00:45 오전 seedu.wildwatch.execute.Router route
INFO: Summary command was input: summary White Rhinoceros
11월 10, 2023 12:00:50 오전 seedu.wildwatch.execute.InputHandler handleInput
INFO: Input received: list
11월 10, 2023 12:00:50 오전 seedu.wildwatch.execute.Router route
INFO: Routing entry for input: list
11월 10, 2023 12:00:50 오전 seedu.wildwatch.execute.Router route
INFO: List command was input: list
11월 10, 2023 12:00:59 오전 seedu.wildwatch.execute.InputHandler handleInput
INFO: Input received: summary Tank
11월 10, 2023 12:00:59 오전 seedu.wildwatch.execute.Router route
INFO: Routing entry for input: summary Tank
11월 10, 2023 12:00:59 오전 seedu.wildwatch.execute.Router route
INFO: Summary command was input: summary Tank
11월 10, 2023 12:00:59 오전 seedu.wildwatch.error.ErrorHandler handleInputError
WARNING: Command is invalid.
11월 10, 2023 12:01:39 오전 seedu.wildwatch.execute.InputHandler handleInput
INFO: Input received: edit I/6 N/Heavy Tank
11월 10, 2023 12:01:39 오전 seedu.wildwatch.execute.Router route
INFO: Routing entry for input: edit I/6 N/Heavy Tank
11월 10, 2023 12:01:39 오전 seedu.wildwatch.execute.Router route
INFO: Edit command was input: edit I/6 N/Heavy Tank
2 changes: 1 addition & 1 deletion src/main/java/seedu/wildwatch/command/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private boolean checkDuplicateEntry(Entry entry, String date, String species, St
String newSpecies = species;

if (date == null || date.isEmpty()) {
newDate = entry.getDate().format(DateTimeFormatter.ofPattern("dd-MM-yy"));
newDate = entry.getDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy"));
}

if (name == null || name.isEmpty()) {
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/seedu/wildwatch/command/SummaryCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ private static Map<String, List<Entry>> groupEntriesBySpecies(List<Entry> entrie
Map<String, List<Entry>> map = new HashMap<String, List<Entry>>();
for (Entry entry : entries) {
String key = entry.getSpecies();
if(map.containsKey(key)){
if (map.containsKey(key)){
List<Entry> list = map.get(key);
list.add(entry);
}else{
} else {
List<Entry> list = new ArrayList<Entry>();
list.add(entry);
map.put(key, list);
Expand All @@ -57,25 +57,26 @@ private static Map<String, List<Entry>> groupSpecieByName(List<Entry> filteredEn

for (Entry entry : filteredEntries) {
String key = entry.getName();
if(filteredMap.containsKey(key)){
if (filteredMap.containsKey(key)) {
List<Entry> list = filteredMap.get(key);
list.add(entry);
}else{
} else {
List<Entry> list = new ArrayList<Entry>();
list.add(entry);
filteredMap.put(key, list);
}
}
return filteredMap;
}

public void execute() throws InvalidInputException {
boolean hasArgument = !this.speciesName.isEmpty();

ArrayList<Entry> entries = EntryList.getArray();
// Group entries by .species attribute
Map<String, List<Entry>> map = groupEntriesBySpecies(entries);
// change message based on whether `summary` or `summary <species>`
if( hasArgument ) {
if (hasArgument) {
SummaryCommandPrinter.printSummaryNameMessage(speciesName);
List<Entry> filteredEntries = map.get(speciesName);
Map<String, List<Entry>> filteredMap = groupSpecieByName(filteredEntries);
Expand Down

0 comments on commit 80bbd7e

Please sign in to comment.