Skip to content

Commit

Permalink
Merge pull request #348 from ziyi105/323-standardise-error-messages-f…
Browse files Browse the repository at this point in the history
…or-decoding-files

Add Javadoc and author tag
  • Loading branch information
DextheChik3n authored Nov 13, 2023
2 parents 8b103eb + 459144d commit 66becd9
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/main/java/seedu/cafectrl/command/HelpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import java.util.logging.Logger;

//@@author ziyi105
/**
* Show a list of commands for users to refer to
*/
public class HelpCommand extends Command {
public static final String COMMAND_WORD = "help";
public static final String MESSAGE_USAGE = "To view all commands:\n"
Expand All @@ -19,6 +22,9 @@ public HelpCommand(Ui ui) {
this.ui = ui;
}

/**
* Call ui to show list of commands
*/
@Override
public void execute() {
logger.info("Executing HelpCommand...");
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/seedu/cafectrl/storage/Decoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ && isValidUnit(unit)) {
return new Pantry(ui, pantryStock);
}

/**
* Checks whether the ingredient name is valid in terms of length, containment of
* special character and whether it is a repeated ingredient
* @param ingredientName name of the ingredient
* @param pantryStock pantry stock with data from previous lines in the text file
* @return true if the name is valid, false otherwise
*/
private static boolean isValidIngredientName(String ingredientName, ArrayList<Ingredient> pantryStock) {
return !Parser.containsSpecialChar(ingredientName)
&& !Parser.isNameLengthInvalid(ingredientName)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/cafectrl/storage/Encoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private static StringBuilder encodeIngredientList(ArrayList<Ingredient> ingredie

//@@author ziyi105
/**
* Encodes the pantry stock into format ingredient name | quantity | unit
* Encodes the pantry stock into format ingredient name | quantity | unit for storage.
* @param pantry the pantry from current session
* @return an arrayList of string of ecoded pantry stock
*/
Expand Down
1 change: 1 addition & 0 deletions src/test/java/seedu/cafectrl/parser/ParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ public void parseCommand_deleteIndexOutOfBounds_returnsErrorMessage() {
assertEquals(ErrorMessages.INVALID_DISH_INDEX, feedbackToUser);
}

//@@author ziyi105
@Test
void parseCommand_unrecognisedInput_unknownCommand() {
Menu menu = new Menu();
Expand Down
1 change: 1 addition & 0 deletions src/test/java/seedu/cafectrl/storage/DecoderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;

//@@author ziyi105
public class DecoderTest {
@Test
void decodePantryStockData_validData_pantryFilledWithStock() {
Expand Down

0 comments on commit 66becd9

Please sign in to comment.