diff --git a/docs/UserGuide.md b/docs/UserGuide.md index abd9fbe891..d9cbd084b8 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -2,41 +2,97 @@ ## Introduction -{Give a product intro} +StockMaster is a platform aimed at helping SMEs track and organise their inventory. ## Quick Start {Give steps to get started quickly} 1. Ensure that you have Java 11 or above installed. -1. Down the latest version of `Duke` from [here](http://link.to/duke). +2. Download the latest version of `StockMaster` from [here](http://link.to/duke). +3. ## Features {Give detailed description of each feature} -### Adding a todo: `todo` -Adds a new item to the list of todo items. +### Adding an item: `add` +Adds a new item to the list of items. -Format: `todo n/TODO_NAME d/DEADLINE` +Format: `add ITEM_NAME qty/ITEM_QUANTITY [cat/CATEGORY]` -* The `DEADLINE` can be in a natural language format. -* The `TODO_NAME` cannot contain punctuation. +* `CATEGORY` is an optional field. If blank, it will default to `N/A`. Example of usage: +``` +add Apples qty/50 +add Phone qty/5 cat/Electronics +``` -`todo n/Write the rest of the User Guide d/next week` +### Deleting an item: `del` +Deletes the item from the list of items. -`todo n/Refactor the User Guide to remove passive voice d/13/04/2020` +Format: `del ITEM_NAME` + +Example of usage: +``` +del Apples +``` + +### Editing an item: `edit` +Edits the quantity of the item. + +Format: `edit ITEM_NAME qty/NEW_QUANTITY` + +Example of usage: +``` +edit Apples qty/10 +edit Phone qty/0 +``` + +### Listing all items: `list` +Lists all stored items. + +Format: `list [cat/CATEGORY]` + +* `CATEGORY` is an optional field. By default, it will list all the stored items. + +Example of usage: +``` +list +list Electronics +``` + +### List all available commands: `help` +Lists all commands as per the command summary below. + +Format: `help [c/COMMAND]` + +* `COMMAND` is optional. Specifying the command will give a more comprehensive + description of the command. + +Example of usage: +``` +help +help c/add +``` + + +### Closing the app: `exit` +Saves and closes the app safely. + +Format: `exit` ## FAQ **Q**: How do I transfer my data to another computer? -**A**: {your answer here} +**A**: Simply copy and paste the saved folder that is created upon launch of +the application. ## Command Summary -{Give a 'cheat sheet' of commands here} - -* Add todo `todo n/TODO_NAME d/DEADLINE` +* Add new item: `add Apples qty/10 cat/Food` +* Delete an item: `delete Apples` +* List all items: `list` +* List all commands: `help` \ No newline at end of file diff --git a/src/main/java/command/Command.java b/src/main/java/command/Command.java index 41649ed097..a71e7f8779 100644 --- a/src/main/java/command/Command.java +++ b/src/main/java/command/Command.java @@ -1,6 +1,8 @@ package command; -public abstract class Command { +import exceptions.CommandFormatException; - public abstract void execute(); +public abstract class Command { + + public abstract void execute() throws CommandFormatException; } diff --git a/src/main/java/command/DeleteCommand.java b/src/main/java/command/DeleteCommand.java index 2da1c3483d..7ce9312919 100644 --- a/src/main/java/command/DeleteCommand.java +++ b/src/main/java/command/DeleteCommand.java @@ -1,7 +1,9 @@ package command; +import exceptions.CommandFormatException; import item.Item; import itemlist.Itemlist; +import parser.CommandType; import storage.Storage; public class DeleteCommand extends Command { @@ -12,7 +14,7 @@ public DeleteCommand(String itemName) { this.itemName = itemName; } - public void execute() { + public void execute() throws CommandFormatException { int index = -1; for (Item item : Itemlist.getItems()) { if (item.getItemName().toLowerCase().equals(itemName)) { @@ -22,6 +24,7 @@ public void execute() { } if (index == -1) { //throw exception; + throw new CommandFormatException(CommandType.DEL); } else { Itemlist.deleteItem(index); } diff --git a/src/main/java/seedu/duke/Duke.java b/src/main/java/seedu/duke/Duke.java index 9af6f9d0f9..8d14fe25b9 100644 --- a/src/main/java/seedu/duke/Duke.java +++ b/src/main/java/seedu/duke/Duke.java @@ -2,6 +2,7 @@ import command.Command; import command.ExitCommand; +import exceptions.CommandFormatException; import parser.Parser; import ui.TextUi; @@ -17,17 +18,17 @@ public class Duke { /** * Main entry-point for the java.duke.Duke application. */ - public static void main(String[] args) throws IOException { + public static void main(String[] args) throws IOException, CommandFormatException { new Duke().run(); } - public void run() throws IOException { + public void run() throws IOException, CommandFormatException { ui.showWelcomeMessage("1.0", "./StockMasterData.txt"); this.normalOperation(); ui.showGoodByeMessage("./StockMasterData.txt"); } - private void normalOperation() throws IOException { + private void normalOperation() throws IOException, CommandFormatException { String userInput; do { userInput = ui.getUserInput(); diff --git a/src/test/java/command/CommandTest.java b/src/test/java/command/CommandTest.java new file mode 100644 index 0000000000..e740812c25 --- /dev/null +++ b/src/test/java/command/CommandTest.java @@ -0,0 +1,13 @@ +package command; + +import org.junit.jupiter.api.Test; + +public class CommandTest { + private Command command; + + @Test + public void command_invalidCommand_throwsError() { + + } + +}