Skip to content

Commit

Permalink
Merge branch 'master' into w13/code-quality
Browse files Browse the repository at this point in the history
  • Loading branch information
RichDom2185 authored Nov 6, 2022
2 parents 9383929 + facee20 commit 4d9d6e4
Show file tree
Hide file tree
Showing 115 changed files with 863 additions and 177 deletions.
1 change: 1 addition & 0 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Here are some links to other documentations you might find useful:
## Requirements

This section shares with you useful information regarding the non-technical aspects of development. This includes:

1. [Product Scope](#product-scope)
1. [User Stories](#user-stories)
1. [Use Cases](#use-cases)
Expand Down
1 change: 1 addition & 0 deletions docs/_ug/commands/GeneralCommands.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
```note
COMMAND_WORD is strictly any of the following:
* exit
* help
* reset
Expand Down
1 change: 1 addition & 0 deletions src/main/java/seedu/foodrem/commons/core/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/**
* Represents a version with major, minor and patch number
* @author
*/
public class Version implements Comparable<Version> {
private static final String VERSION_REGEX = "V(\\d+)\\.(\\d+)\\.(\\d+)(ea)?";
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/seedu/foodrem/commons/core/index/Index.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ public static Index fromOneBased(int oneBasedIndex) {
return new Index(oneBasedIndex - 1);
}

/**
* Returns the zeroBasedIndex.
*/
public int getZeroBased() {
return zeroBasedIndex;
}

/**
* Returns the oneBasedIndex.
*/
public int getOneBased() {
return zeroBasedIndex + 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
* Represents an error during conversion of data from one format to another
*/
public class DataConversionException extends Exception {
/**
* Constructs a DataConversionException.
*/
public DataConversionException(Exception cause) {
super(cause);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
* Represents an error when more items are added when the storage is full.
*/
public class ItemStorageFullException extends StorageFullException {
/**
* Constructs an ItemStorageFullException.
*/
public ItemStorageFullException(int maxNumberOfItems) {
super(String.format("The item storage is full. FoodRem can only hold up to %s items.", maxNumberOfItems));
}

/**
* Constructs an ItemStorageFullException.
*/
public ItemStorageFullException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
* Represents an error when the storage is full.
*/
public class StorageFullException extends RuntimeException {
/**
* Constructs a StorageFullException.
*/
public StorageFullException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
* Represents an error when more items are added when the storage is full.
*/
public class TagStorageFullException extends StorageFullException {
/**
* Constructs a TagStorageFullException.
*/
public TagStorageFullException(int maxNumberOfTags) {
super(String.format("The tag storage is full. FoodRem can only hold up to %s tags.", maxNumberOfTags));
}

/**
* Constructs a TagStorageFullException.
*/
public TagStorageFullException(String message) {
super(message);
}
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/seedu/foodrem/logic/LogicManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public LogicManager(Model model, Storage storage) {
foodRemParser = new FoodRemParser();
}

/**
* @inheritDoc
*/
@Override
public CommandResult<?> execute(String commandText) throws CommandException, ParseException {
logger.info("----------------[USER COMMAND][" + commandText + "]");
Expand All @@ -54,26 +57,41 @@ public CommandResult<?> execute(String commandText) throws CommandException, Par
return commandResult;
}

/**
* {@inheritDoc}
*/
@Override
public ReadOnlyFoodRem getFoodRem() {
return model.getFoodRem();
}

/**
* {@inheritDoc}
*/
@Override
public ObservableList<Item> getCurrentList() {
return model.getCurrentList();
}

/**
* {@inheritDoc}
*/
@Override
public Path getFoodRemFilePath() {
return model.getFoodRemFilePath();
}

/**
* {@inheritDoc}
*/
@Override
public GuiSettings getGuiSettings() {
return model.getGuiSettings();
}

/**
* {@inheritDoc}
*/
@Override
public void setGuiSettings(GuiSettings guiSettings) {
model.setGuiSettings(guiSettings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
* Terminates the program.
*/
public class ExitCommand extends Command {
/**
* {@inheritDoc}
*/
@Override
public CommandResult<String> execute(Model model) {
return new CommandResult<>() {
Expand Down Expand Up @@ -44,6 +47,11 @@ public boolean equals(Object other) {
};
}

/**
* Returns a string representing how to use the command.
*
* @return a string representing how to use the command.
*/
public static String getUsage() {
return EXIT_COMMAND.getUsage();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import seedu.foodrem.model.Model;

/**
* Format full help instructions for every command for display.
* Formats full help instructions for every command for display.
*/
public class HelpCommand extends Command {
public static final String DEFAULT_HELP_MESSAGE = "Please refer to the user guide.";
Expand Down Expand Up @@ -38,34 +38,55 @@ public HelpCommand(String message) {
this.message = message;
}

/**
* Returns a command help message.
*/
public static String getCommandHelpMessage(CommandType command) {
return String.format(HELP_FORMAT_SPECIFIC, command.getUsage());
}

/**
* Returns a general help message.
*/
public static String getGeneralHelpMessage() {
return HELP_FORMAT_GENERAL;
}

/**
* {@inheritDoc}
*/
@Override
public CommandResult<String> execute(Model model) {
return new CommandResult<>() {
/**
* {@inheritDoc}
*/
@Override
public String getOutput() {
return SHOWING_HELP_MESSAGE;
}

/**
* {@inheritDoc}
*/
@Override
public boolean shouldShowHelp() {
return true;
}

/**
* {@inheritDoc}
*/
@Override
public String getHelpText() {
assert message != null;
return message;
}

// TODO: Test this
/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object other) {
if (other == this) {
Expand All @@ -87,10 +108,18 @@ && getHelpText().equals(asType.getHelpText())
};
}

/**
* Returns a string representing how to use the command.
*
* @return a string representing how to use the command.
*/
public static String getUsage() {
return HELP_COMMAND.getUsage();
}

/**
* Returns {@code true} if both {@link HelpCommand} are equal.
*/
@Override
public boolean equals(Object other) {
return other == this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,22 @@
* Resets FoodRem.
*/
public class ResetCommand extends Command {

/**
* {@inheritDoc}
*/
@Override
public CommandResult<String> execute(Model model) {
requireNonNull(model);
model.setFoodRem(new FoodRem());
return CommandResult.from("FoodRem has been reset!");
}

/**
* Returns a string representing how to use the command.
*
* @return a string representing how to use the command.
*/
public static String getUsage() {
return RESET_COMMAND.getUsage();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ private static Item createDecrementedItem(Item itemToDecrement, ItemQuantity qua
itemToDecrement.getTagSet());
}

/**
* {@inheritDoc}
*/
@Override
public CommandResult<ItemWithMessage> execute(Model model) throws CommandException {
requireNonNull(model);
Expand All @@ -76,6 +79,9 @@ public CommandResult<ItemWithMessage> execute(Model model) throws CommandExcepti
"Decremented successfully and updated item as follows:"));
}

/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object other) {
return other == this
Expand All @@ -84,6 +90,11 @@ public boolean equals(Object other) {
&& quantity.equals(((DecrementCommand) other).quantity));
}

/**
* Returns a string representing how to use the command.
*
* @return a string representing how to use the command.
*/
public static String getUsage() {
return DECREMENT_COMMAND.getUsage();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public DeleteCommand(Index index) {
this.index = index;
}

/**
* {@inheritDoc}
*/
@Override
public CommandResult<ItemWithMessage> execute(Model model) throws CommandException {
requireNonNull(model);
Expand All @@ -39,6 +42,11 @@ public CommandResult<ItemWithMessage> execute(Model model) throws CommandExcepti
"Successfully deleted the following item:"));
}

/**
* Returns a string representing how to use the command.
*
* @return a string representing how to use the command.
*/
public static String getUsage() {
return DELETE_COMMAND.getUsage();
}
Expand Down
Loading

0 comments on commit 4d9d6e4

Please sign in to comment.