Skip to content

Commit

Permalink
Merge pull request nus-cs2103-AY2021S1#90 from BILLXYR/branch-ModifyC…
Browse files Browse the repository at this point in the history
…heckStyle

Modify checkStyle
  • Loading branch information
yyutong authored Oct 18, 2020
2 parents 4bf6cdb + 28ad9a7 commit 2fc4ac7
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 55 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package seedu.address.logic.commands;

import seedu.address.model.Model;

import static seedu.address.commons.util.CollectionUtil.requireAllNonNull;

import seedu.address.model.Model;

public class SetBudgetCommand extends Command {
public static final String COMMAND_WORD = "setBudget";
public static final String MESSAGE_SET_BUDGET_SUCCESS = "Successful! The budget is now S$ %.2f.\n";
public static final String MESSAGE_SET_BUDGET_FAIL = "Set Budget failed, please enter a valid budget.\n";

private final double budget;

/**
* Construct a SetBudget object.
*/
public SetBudgetCommand(double budget) {
requireAllNonNull(budget);
this.budget = budget;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
package seedu.address.logic.commands;

import java.util.List;

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";
+ "Example: " + COMMAND_WORD;
public static final String MESSAGE_VIEW_CATEGORY_LABELS_SUCCESS = "View all the existing category labels: \n";

public ViewCategoryCommand() {
}
Expand All @@ -26,7 +22,7 @@ public ViewCategoryCommand() {
public CommandResult execute(Model model) throws CommandException {
String message = "";
List<Category> categories = model.getCategoryLabels();
for (int i = 0; i < categories.size(); i++){
for (int i = 0; i < categories.size(); i++) {
message = message + categories.get(i).categoryName + "\n";
}
return new CommandResult(MESSAGE_VIEW_CATEGORY_LABELS_SUCCESS + message);
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/seedu/address/logic/commands/ViewCommand.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package seedu.address.logic.commands;

import static java.util.Objects.requireNonNull;

import java.util.List;

import seedu.address.commons.core.Messages;
Expand All @@ -10,7 +8,6 @@
import seedu.address.model.Model;
import seedu.address.model.person.Expense;

import static java.util.Objects.requireNonNull;

public class ViewCommand extends Command {
public static final String COMMAND_WORD = "view";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public DeleteDescriptionCommand parse(String args) throws ParseException {
try {
index = ParserUtil.parseIndex(argMultimap.getPreamble());
} catch (IllegalValueException ive) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, DescriptionCommand.MESSAGE_USAGE), ive);
throw new ParseException(String.format(
MESSAGE_INVALID_COMMAND_FORMAT, DescriptionCommand.MESSAGE_USAGE), ive);
}

return new DeleteDescriptionCommand(index);
Expand Down
15 changes: 6 additions & 9 deletions src/main/java/seedu/address/logic/parser/ExpenseBookParser.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package seedu.address.logic.parser;

import seedu.address.logic.commands.*;
import seedu.address.logic.parser.exceptions.ParseException;
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.commons.core.Messages.MESSAGE_UNKNOWN_COMMAND;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand All @@ -11,17 +11,15 @@
import seedu.address.logic.commands.DeleteDescriptionCommand;
import seedu.address.logic.commands.DeleteExpenseCommand;
import seedu.address.logic.commands.DescriptionCommand;
import seedu.address.logic.commands.ListExpenseCommand;
import seedu.address.logic.commands.ListExpenseByCategoryCommand;
import seedu.address.logic.commands.HelpCommand;
import seedu.address.logic.commands.ViewCommand;
import seedu.address.logic.commands.ListExpenseByCategoryCommand;
import seedu.address.logic.commands.ListExpenseCommand;
import seedu.address.logic.commands.SetBudgetCommand;
import seedu.address.logic.commands.ShowBudgetCommand;
import seedu.address.logic.commands.ViewCategoryCommand;
import seedu.address.logic.commands.ViewCommand;
import seedu.address.logic.parser.exceptions.ParseException;

import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.commons.core.Messages.MESSAGE_UNKNOWN_COMMAND;

/**
* Parses user input.
*/
Expand Down Expand Up @@ -73,7 +71,6 @@ public Command parseCommand(String userInput) throws ParseException {

case SetBudgetCommand.COMMAND_WORD:
return new SetBudgetCommandParser().parse(arguments);

default:
throw new ParseException(MESSAGE_UNKNOWN_COMMAND);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package seedu.address.logic.parser;

import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.DeleteCommand;
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;

import seedu.address.logic.commands.SetBudgetCommand;
import seedu.address.logic.parser.exceptions.ParseException;

import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;

public class SetBudgetCommandParser implements Parser<SetBudgetCommand> {
@Override
public SetBudgetCommand parse(String userInput) throws ParseException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package seedu.address.logic.parser;

import seedu.address.logic.commands.DescriptionCommand;
import seedu.address.logic.commands.ShowBudgetCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.person.Description;

public class ShowBudgetCommandParser implements Parser<ShowBudgetCommand> {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
package seedu.address.logic.parser;

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>{
public class ViewCategoryCommandParser implements Parser<ViewCategoryCommand> {
@Override
public ViewCategoryCommand parse(String args) throws ParseException {
return new ViewCategoryCommand();
Expand Down
11 changes: 3 additions & 8 deletions src/main/java/seedu/address/logic/parser/ViewCommandParser.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
package seedu.address.logic.parser;

import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_CATEGORY;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;

import seedu.address.commons.exceptions.IllegalValueException;
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;

import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.DeleteCommand;
import seedu.address.logic.commands.ViewCommand;
import seedu.address.logic.parser.exceptions.ParseException;

Expand All @@ -21,10 +16,10 @@ public class ViewCommandParser {
*/
public ViewCommand parse(String args) throws ParseException {
requireNonNull(args);
try{
try {
Index index = ParserUtil.parseIndex(args);
return new ViewCommand(index);
} catch(ParseException e) {
} catch (ParseException e) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT,
ViewCommand.MESSAGE_USAGE));
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/model/ExpenseBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void setExpense(Expense target, Expense editedExpense) {
expenses.setExpense(target, editedExpense);
}

public void viewExpense(Index index){
public void viewExpense(Index index) {
expenses.view(index);
}

Expand Down Expand Up @@ -146,7 +146,7 @@ public double getRemainingBudget() {
}
//end of yuanxing edits

public List<Category> getCategoryLabels(){
public List<Category> getCategoryLabels() {
return expenses.getCategoryLabels();
}

Expand Down
1 change: 0 additions & 1 deletion src/main/java/seedu/address/model/ExpenseModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import javafx.collections.transformation.FilteredList;
import seedu.address.commons.core.GuiSettings;
import seedu.address.commons.core.LogsCenter;
import seedu.address.commons.core.index.Index;
import seedu.address.model.person.Category;
import seedu.address.model.person.Expense;
import seedu.address.model.person.Person;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void add(Expense toAdd) {
*
* @param index The index of the expense to be viewed in the ExpenseBook.
*/
public void view(Index index){
public void view (Index index) {
requireAllNonNull(index);
Expense expense = internalList.get(index.getOneBased());
}
Expand Down Expand Up @@ -166,12 +166,12 @@ public double getRemainingBudget() {
return this.budget - used;
}

public List<Category> getCategoryLabels(){
public List<Category> getCategoryLabels() {
List<Category> categories = new ArrayList<>();
for(int i = 0; i < internalList.size(); i++) {
for (int i = 0; i < internalList.size(); i++) {
Expense current = internalList.get(i);
Category currentCategory = current.getCategory();
if(!categories.contains(currentCategory)){
if (!categories.contains(currentCategory)) {
categories.add(currentCategory);
}
}
Expand Down

0 comments on commit 2fc4ac7

Please sign in to comment.