Skip to content

Commit

Permalink
Merge pull request nus-cs2103-AY2021S1#80 from yuanxing-y/master
Browse files Browse the repository at this point in the history
Fix nits in conflicts
  • Loading branch information
yuanxing-z authored Oct 14, 2020
2 parents 8f89d61 + 7e94a24 commit 176a6a3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package seedu.address.logic.commands;

import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;

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

public class SetBudgetCommand extends Command {
public static final String COMMAND_WORD = "setBudget";
public static final String MESSAGE_SET_BUDGET_SUCCESS = "Successful! Te budget is now S$ %.2f.\n";
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;
Expand All @@ -18,7 +17,7 @@ public SetBudgetCommand(double budget) {
}

@Override
public CommandResult execute(Model model) throws CommandException {
public CommandResult execute(Model model) {
model.setExpenseBookBudget(budget);
String msg = String.format(MESSAGE_SET_BUDGET_SUCCESS, budget);
return new CommandResult(msg);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package seedu.address.logic.commands;

import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;

public class ShowBudgetCommand extends Command {

public static final String COMMAND_WORD = "showBudget";
public static final String MESSAGE_BUDGET = "Current budget is: S$ %.2f\n";
public static final String MESSAGE_REMAINING = "Remaining budget is: S$ %.2f\n";
public static final String MESSAGE_SETNEW = "Your current budget is S$0.00, \n"
public static final String MESSAGE_SETNEW = "Your current budget is S$ %.2f, \n"
+ "please set a new budget with command: setBudget AMOUNT\n";

@Override
public CommandResult execute(Model model) throws CommandException {
if (model.getExpenseBookBudget() == 0) {
return new CommandResult(MESSAGE_SETNEW);
public CommandResult execute(Model model) {
double budget = model.getExpenseBookBudget();
if (model.getExpenseBookBudget() <= 0) {
String setNew = String.format(MESSAGE_SETNEW, budget);
return new CommandResult(setNew);
} else {
String budgetMsg = String.format(MESSAGE_BUDGET, model.getExpenseBookBudget());
String budgetMsg = String.format(MESSAGE_BUDGET, budget);
String remainingMsg = String.format(MESSAGE_REMAINING, model.getExpenseBookRemaining());

return new CommandResult(budgetMsg + remainingMsg);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ public Command parseCommand(String userInput) throws ParseException {
switch (commandWord) {
case DescriptionCommand.COMMAND_WORD:
return new DescriptionCommandParser().parse(arguments);

case AddExpenseCommand.COMMAND_WORD:
return new AddExpenseCommandParser().parse(arguments);

case DeleteExpenseCommand.COMMAND_WORD:
return new DeleteExpenseCommandParser().parse(arguments);

case ListExpenseCommand.COMMAND_WORD:
return new ListExpenseCommand();

case DescriptionCommand.COMMAND_WORD:
return new DescriptionCommandParser().parse(arguments);
case DeleteDescriptionCommand.COMMAND_WORD:
return new DeleteDescriptionCommandParser().parse(arguments);

Expand All @@ -63,8 +63,9 @@ public Command parseCommand(String userInput) throws ParseException {

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

default:
throw new ParseException(MESSAGE_UNKNOWN_COMMAND);
throw new ParseException(MESSAGE_UNKNOWN_COMMAND);
}
}
}

0 comments on commit 176a6a3

Please sign in to comment.