forked from nus-cs2103-AY2021S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from yyutong/command-view-category
Add view category command
- Loading branch information
Showing
12 changed files
with
125 additions
and
45 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
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
33 changes: 32 additions & 1 deletion
33
src/main/java/seedu/address/logic/commands/ViewCategoryCommand.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 |
---|---|---|
@@ -1,4 +1,35 @@ | ||
package seedu.address.logic.commands; | ||
|
||
public class ViewCategoryCommand { | ||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.person.Category; | ||
import seedu.address.model.person.Expense; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class ViewCategoryCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "viewCategory"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD | ||
+ ": Finds all the category labels used in the ExpenseBook so far. \n" | ||
+ "Example: " + COMMAND_WORD ; | ||
|
||
public static final String MESSAGE_VIEW_CATEGORY_LABELS_SUCCESS = | ||
"View all the existing category labels: \n"; | ||
|
||
public ViewCategoryCommand() { | ||
} | ||
|
||
@Override | ||
public CommandResult execute(Model model) throws CommandException { | ||
String message = ""; | ||
List<Category> categories = model.getCategoryLabels(); | ||
for (int i = 0; i < categories.size(); i++){ | ||
message = message + categories.get(i).categoryName + "\n"; | ||
} | ||
return new CommandResult(MESSAGE_VIEW_CATEGORY_LABELS_SUCCESS + message); | ||
} | ||
|
||
} |
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
18 changes: 17 additions & 1 deletion
18
src/main/java/seedu/address/logic/parser/ViewCategoryCommandParser.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 |
---|---|---|
@@ -1,4 +1,20 @@ | ||
package seedu.address.logic.parser; | ||
|
||
public class ViewCategoryCommandParser { | ||
import seedu.address.commons.core.index.Index; | ||
import seedu.address.commons.exceptions.IllegalValueException; | ||
import seedu.address.logic.commands.DescriptionCommand; | ||
import seedu.address.logic.commands.ShowBudgetCommand; | ||
import seedu.address.logic.commands.ViewCategoryCommand; | ||
import seedu.address.logic.parser.exceptions.ParseException; | ||
import seedu.address.model.person.Description; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_CATEGORY; | ||
|
||
public class ViewCategoryCommandParser implements Parser<ViewCategoryCommand>{ | ||
@Override | ||
public ViewCategoryCommand parse(String args) throws ParseException { | ||
return new ViewCategoryCommand(); | ||
} | ||
} |
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
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