Skip to content

Commit

Permalink
Merge pull request #208 from shirsho-12/uml-diagrams
Browse files Browse the repository at this point in the history
Quality of Life refactors
  • Loading branch information
shirsho-12 authored Apr 4, 2023
2 parents bd658d6 + 5e61574 commit 228fbfd
Show file tree
Hide file tree
Showing 67 changed files with 834 additions and 222 deletions.
63 changes: 63 additions & 0 deletions data/addressbook.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"categories" : [ {
"categoryName" : "food",
"summary" : "For food"
}, {
"categoryName" : "entertainment",
"summary" : "For entertainment"
}, {
"categoryName" : "transportation",
"summary" : "For bus, car, train"
}, {
"categoryName" : "shopping",
"summary" : ""
}, {
"categoryName" : "housing",
"summary" : ""
} ],
"expenses" : [ {
"name" : "Meal at JE",
"amount" : "4.5",
"date" : "2023-04-04",
"category" : {
"categoryName" : "food",
"summary" : "For food"
}
}, {
"name" : "Groceries",
"amount" : "56.3",
"date" : "2023-03-25",
"category" : {
"categoryName" : "food",
"summary" : "For food"
}
}, {
"name" : "Shoes",
"amount" : "75.0",
"date" : "2023-03-20",
"category" : {
"categoryName" : "shopping",
"summary" : ""
}
}, {
"name" : "Movie ticket",
"amount" : "12.99",
"date" : "2023-03-15",
"category" : {
"categoryName" : "entertainment",
"summary" : "For entertainment"
}
}, {
"name" : "MRT fare",
"amount" : "45.8",
"date" : "2023-03-10",
"category" : {
"categoryName" : "transportation",
"summary" : "For bus, car, train"
}
} ],
"budget" : {
"amount" : "0.0"
},
"recurringGenerators" : [ ]
}
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/logic/commands/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* Represents a command with hidden internal logic and the ability to be executed.
*/
public abstract class Command {
public interface Command {

/**
* Executes the command and returns the result message.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* Sets the monthly budget for FastTrack.
*/
public class SetBudgetCommand extends Command {
public class SetBudgetCommand implements Command {


public static final String COMMAND_WORD = "set";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package seedu.address.logic.commands;
package seedu.address.logic.commands.add;

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_CATEGORY;
import static seedu.address.logic.parser.CliSyntax.PREFIX_SUMMARY;

import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.category.Category;
Expand All @@ -12,7 +13,7 @@
/**
* Adds a category to the Expense Tracker.
*/
public class AddCategoryCommand extends Command {
public class AddCategoryCommand implements AddCommand {

public static final String COMMAND_WORD = "addcat";
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a category to FastTrack. "
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package seedu.address.logic.commands.add;

import seedu.address.logic.commands.Command;

/**
* Represents an add command with hidden internal logic and the ability to be
* executed.
*/
public interface AddCommand extends Command {}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package seedu.address.logic.commands;
package seedu.address.logic.commands.add;

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_CATEGORY;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DATE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PRICE;

import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.category.Category;
Expand All @@ -16,7 +17,7 @@
/**
* Adds an expense to the Expense Tracker.
*/
public class AddExpenseCommand extends Command {
public class AddExpenseCommand implements AddCommand {

public static final String COMMAND_WORD = "add";
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds an expense to FastTrack "
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.address.logic.commands;
package seedu.address.logic.commands.add;

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_CATEGORY;
Expand All @@ -8,6 +8,7 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_START_DATE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TIMESPAN;

import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.category.Category;
Expand All @@ -17,7 +18,7 @@
/**
* Adds a category to the Expense Tracker.
*/
public class AddRecurringExpenseCommand extends Command {
public class AddRecurringExpenseCommand implements AddCommand {

public static final String COMMAND_WORD = "addrec";
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a recurring expense to FastTrack. "
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package seedu.address.logic.commands;
package seedu.address.logic.commands.delete;

import static java.util.Objects.requireNonNull;

import java.util.List;

import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.category.Category;
Expand All @@ -14,7 +15,7 @@
/**
* Deletes a category identified using it's displayed index from the expense tracker.
*/
public class DeleteCategoryCommand extends Command {
public class DeleteCategoryCommand implements DeleteCommand {

public static final String COMMAND_WORD = "delcat";

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

import seedu.address.logic.commands.Command;

/**
* Represents a delete command with hidden internal logic and the ability to be executed.
*/
public interface DeleteCommand extends Command {
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package seedu.address.logic.commands;
package seedu.address.logic.commands.delete;

import static java.util.Objects.requireNonNull;

import java.util.List;

import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.expense.Expense;
Expand All @@ -14,7 +15,7 @@
/**
* Deletes an expense from the expense tracker.
*/
public class DeleteExpenseCommand extends Command {
public class DeleteExpenseCommand implements DeleteCommand {

public static final String COMMAND_WORD = "delete";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package seedu.address.logic.commands;
package seedu.address.logic.commands.delete;

import static java.util.Objects.requireNonNull;

import java.util.List;

import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.expense.RecurringExpenseManager;
Expand All @@ -14,7 +15,7 @@
/**
* Deletes an expense from the expense tracker.
*/
public class DeleteRecurringExpenseCommand extends Command {
public class DeleteRecurringExpenseCommand implements DeleteCommand {

public static final String COMMAND_WORD = "delrec";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package seedu.address.logic.commands;
package seedu.address.logic.commands.edit;

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.commands.AddCategoryCommand.MESSAGE_DUPLICATE_CATEGORY;
import static seedu.address.logic.commands.add.AddCategoryCommand.MESSAGE_DUPLICATE_CATEGORY;
import static seedu.address.logic.parser.CliSyntax.PREFIX_CATEGORY;
import static seedu.address.logic.parser.CliSyntax.PREFIX_SUMMARY;

import java.util.List;

import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.category.Category;
Expand All @@ -19,7 +20,7 @@
/**
* Edits a category in the ExpenseTracker
*/
public class EditCategory extends Command {
public class EditCategoryCommand implements EditCommand {
public static final String COMMAND_WORD = "edcat";

public static final String MESSAGE_USAGE = COMMAND_WORD
Expand All @@ -33,19 +34,19 @@ public class EditCategory extends Command {

private final String newCategoryName;

private final String newSummaryName;
private final String newSummary;

/**
* Creates an EditCategory to edit the specified {@code Category}
* @param targetIndex index of the expense in the filtered category list to edit.
* @param newCategoryName String representation of the new category name to be edited to, if applicable.
* @param newSummaryName String representation of the new summary name to be edited to, if applicable.
* @param newSummary String representation of the new summary to be edited to, if applicable.
*/
public EditCategory(Index targetIndex, String newCategoryName, String newSummaryName) {
public EditCategoryCommand(Index targetIndex, String newCategoryName, String newSummary) {
requireNonNull(targetIndex);
this.targetIndex = targetIndex;
this.newCategoryName = newCategoryName;
this.newSummaryName = newSummaryName;
this.newSummary = newSummary;
}


Expand All @@ -69,11 +70,11 @@ public CommandResult execute(Model model) throws CommandException {
throw new CommandException(MESSAGE_DUPLICATE_CATEGORY);
}
}
if (newSummaryName != null) {
categoryToEdit.setDescription(newSummaryName.replaceAll("\\s+", " "));
if (newSummary != null) {
categoryToEdit.setDescription(newSummary.replaceAll("\\s+", " "));
}

if (newCategoryName == null && newSummaryName == null) {
if (newCategoryName == null && newSummary == null) {
throw new CommandException(Messages.MESSAGE_INVALID_EDIT_FOR_CATEGORIES);
}

Expand All @@ -86,7 +87,7 @@ public CommandResult execute(Model model) throws CommandException {
@Override
public boolean equals(Object other) {
return other == this // short circuit if same object
|| (other instanceof EditCategory // instanceof handles nulls
&& targetIndex.equals(((EditCategory) other).targetIndex)); // state check
|| (other instanceof EditCategoryCommand // instanceof handles nulls
&& targetIndex.equals(((EditCategoryCommand) other).targetIndex)); // state check
}
}
11 changes: 11 additions & 0 deletions src/main/java/seedu/address/logic/commands/edit/EditCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package seedu.address.logic.commands.edit;

import seedu.address.logic.commands.Command;

/**
* Represents a edit command with hidden internal logic and the ability to be
* executed.
*/
public interface EditCommand extends Command {

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.address.logic.commands;
package seedu.address.logic.commands.edit;

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_CATEGORY;
Expand All @@ -11,6 +11,7 @@

import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.category.Category;
Expand All @@ -21,7 +22,7 @@
/**
* Edits an Expense in the expense tracker.
*/
public class EditExpenseCommand extends Command {
public class EditExpenseCommand implements EditCommand {
public static final String COMMAND_WORD = "edexp";
public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Edits the expense identified by the index number used in the displayed expenses list.\n"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.address.logic.commands;
package seedu.address.logic.commands.edit;

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_CATEGORY;
Expand All @@ -12,6 +12,7 @@

import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.category.Category;
Expand All @@ -23,7 +24,7 @@
/**
* Edits a RecurringExpenseManager in the ExpenseTracker
*/
public class EditRecurringExpenseManagerCommand extends Command {
public class EditRecurringExpenseManagerCommand implements EditCommand {
public static final String COMMAND_WORD = "edrec";
public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Edits the recurring expense identified by the index number used in the displayed recurring"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package seedu.address.logic.commands;
package seedu.address.logic.commands.general;

import static java.util.Objects.requireNonNull;

import java.util.List;

import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.category.Category;
Expand All @@ -14,7 +15,7 @@
/**
* Displays the summary of an expense
*/
public class CategorySummaryCommand extends Command {
public class CategorySummaryCommand implements GeneralCommand {

public static final String COMMAND_WORD = "scat";
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Displays summary of category "
Expand Down
Loading

0 comments on commit 228fbfd

Please sign in to comment.