From 3590c878ba8c19ef6c9e57a7a6258be250a46b06 Mon Sep 17 00:00:00 2001 From: hshiah Date: Thu, 2 Nov 2023 23:04:54 +0800 Subject: [PATCH 1/3] Update UG. Fix some minor errors of reminder and goal. Update the saving and loading for goals and reminder. --- docs/UserGuide.md | 158 +++++++++++++++++- .../seedu/financialplanner/goal/Goal.java | 14 +- .../seedu/financialplanner/goal/WishList.java | 7 +- .../financialplanner/reminder/Reminder.java | 11 +- .../reminder/ReminderList.java | 7 +- .../financialplanner/storage/LoadData.java | 43 +++++ .../financialplanner/storage/SaveData.java | 10 ++ 7 files changed, 244 insertions(+), 6 deletions(-) diff --git a/docs/UserGuide.md b/docs/UserGuide.md index 3d9ba441d8..208749fd39 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -28,7 +28,15 @@ * [WatchList](#viewing-watchlist-watchlist) * [Adding Stock](#adding-stock-to-watchlist-addstock) * [Deleting Stock](#deleting-budget-budget-delete) - * [Visualization](#Visualization) + * [ReminderList](#view-reminder-list-reminderlist) + * [Adding Reminder](#add-reminder-addreminder) + * [Deleting Reminder](#delete-reminder-deletereminder) + * [Marking Reminder as Done](#mark-reminder-as-done-markreminder) + * [WishList](#view-goal-list-wishlist) + * [Adding Goal](#set-goal-set-goal) + * [Deleting Goal](#delete-goal-deletegoal) + * [Marking Goal as Achieved](#mark-goal-as-achieved-markgoal) + * [Visualization](#visualizing-your-cashflow-vis) * [Exiting the program](#exiting-the-program-exit) * [Saving data](#saving-the-data) * [Loading data](#loading-the-data) @@ -539,6 +547,154 @@ Use watchlist command to view updated Watchlist - Note: Your watchlist information is saved under the file path `data/watchlist.json` in JSON format +### View Reminder List: `reminderlist` +View your current reminder list with reminders that you have added. + +Format: `reminderlist` + +Example of usage: `reminderlist` + +Example of output: + +``` +Here is your reminder list: +1. Reminder + Type: debt + Date: 2023.12.11 + Status: Not Done +2. Reminder + Type: loan + Date: 2023.12.18 + Status: Not Done +``` + +### Add reminder: `addreminder` +Adds a reminder to the Financial Planner. + +Format: `addreminder /t TYPE /d DATE` +- `/t` is used to specify the reminder type, which describes what is the reminder used for. +- `/d` is used to give a deadline date to the reminder. + +Example of usage: `addreminder /t debt /d 2023.12.11` + +Example output: +``` +You have added Reminder + Type: debt + Date: 2023.12.11 + Status: Not Done +``` + +### Delete reminder: `deletereminder` +Deletes a reminder from the Financial Planner. + +Format: `deletereminder INDEX` + +- `INDEX` refers to the index number shown in the displayed list when [`reminderlist`](#view-reminder-list-reminderlist) command is used. + +Example of usage: `deletereminder 1` + +Example output: +``` +You have deleted Reminder + Type: debt + Date: 2023.12.11 + Status: Not Done +``` + +### Mark reminder as done: `markreminder` +Marks a reminder as done in the Financial Planner. + +Format: `markreminder INDEX` + +- `INDEX` refers to the index number shown in the displayed list when [`reminderlist`](#view-reminder-list-reminderlist) command is used. + +Example of usage: `markreminder 1` + +Example output: +``` +You have marked Reminder + Type: debt + Date: 2023.12.11 + Status: Done +``` + +### View Goal List: `wishlist` +View your current goal list with goals that you have added. + +Format: `wishlist` + +Example of usage: `wishlist` + +Example of output: +``` +Here is your wish list: +1. Goal + Label: car + Amount: 5000 + Status: Not Achieved +2. Goal + Label: ipad + Amount: 2000 + Status: Not Achieved +``` + +### Set goal: `set goal` +Adds a goal to the Financial Planner. + +Format: `set goal /g GOAL /l LABEL` +- `/g` is used to specify the goal amount. +- `/l` is used to give a label to the goal. + +Example of usage: `set goal /g 5000 /l car` + +Example output: +``` +You have added Goal + Label: car + Amount: 5000 + Status: Not Achieved +``` + +### Delete goal: `deletegoal` +Deletes a goal from the Financial Planner. + +Format: `deletegoal INDEX` +- `INDEX` refers to the index number shown in the displayed list when [`wishlist`](#view-goal-list-wishlist) command is used. + +Example of usage: `deletegoal 1` + +Example output: +``` +You have deleted Goal + Label: car + Amount: 5000 + Status: Not Achieved +``` + +### Mark goal as achieved: `markgoal` +Marks a goal as achieved in the Financial Planner. This operation will automatically create a corresponding expense. + +Format: `markgoal INDEX` +- `INDEX` refers to the index number shown in the displayed list when [`wishlist`](#view-goal-list-wishlist) command is used. + +Example of usage: `markgoal 1` + +Example output: +``` +You have achieved Goal + Label: ipad + Amount: 2000 + Status: Achieved +Congratulations! +You have added an Expense + Type: Others + Amount: 2000.00 + Description: ipad +to the Financial Planner. +Balance: -2000.00 +``` + ### Visualizing your cashflow: `vis` Using this command to visualize your income or expenses in a pie chart, bar chart or radar chart diff --git a/src/main/java/seedu/financialplanner/goal/Goal.java b/src/main/java/seedu/financialplanner/goal/Goal.java index e3541a933e..e7eac78a6a 100644 --- a/src/main/java/seedu/financialplanner/goal/Goal.java +++ b/src/main/java/seedu/financialplanner/goal/Goal.java @@ -10,6 +10,16 @@ public Goal(String label, int amount) { this.amount = amount; } + public Goal(String label, int amount, String status) { + this.label = label; + this.amount = amount; + if (status.equals("Achieved")) { + this.isDone = true; + } else { + this.isDone = false; + } + } + public String toString() { String status = isDone ? "Achieved" : "Not Achieved"; return "Goal " + System.lineSeparator()+ " Label: " + label + System.lineSeparator() + " Amount: " + @@ -27,7 +37,7 @@ public int getAmount() { return this.amount; } public String formatString() { - String status = isDone ? "Done" : "Not Done"; - return this.label + " | " + this.amount + " | " + this.isDone; + String status = isDone ? "Achieved" : "Not Achieved"; + return "G" + " | " + this.label + " | " + this.amount + " | " + status; } } diff --git a/src/main/java/seedu/financialplanner/goal/WishList.java b/src/main/java/seedu/financialplanner/goal/WishList.java index f00083f66b..b03ae4704b 100644 --- a/src/main/java/seedu/financialplanner/goal/WishList.java +++ b/src/main/java/seedu/financialplanner/goal/WishList.java @@ -28,7 +28,12 @@ public void deleteGoal(int index) { public String toString() { String result = ""; for (int i = 0; i < list.size(); i++) { - result += String.format("%d. %s\n", i + 1, list.get(i)); + if (i == list.size() - 1) { + result += String.format("%d. %s", i + 1, list.get(i)); + break; + } else { + result += String.format("%d. %s\n", i + 1, list.get(i)); + } } return result; } diff --git a/src/main/java/seedu/financialplanner/reminder/Reminder.java b/src/main/java/seedu/financialplanner/reminder/Reminder.java index 1ac0388a04..d32c683823 100644 --- a/src/main/java/seedu/financialplanner/reminder/Reminder.java +++ b/src/main/java/seedu/financialplanner/reminder/Reminder.java @@ -10,6 +10,15 @@ public Reminder(String type, String date) { this.date = date; } + public Reminder(String type, String date, String status) { + this.type = type; + this.date = date; + if (status.equals("Done")) { + this.isDone = true; + } else { + this.isDone = false; + } + } public String toString() { String status = isDone ? "Done" : "Not Done"; return "Reminder " + System.lineSeparator() + " Type: " + type + System.lineSeparator() @@ -29,6 +38,6 @@ public void unmark() { */ public String formatString() { String status = isDone ? "Done" : "Not Done"; - return this.type + " | " + this.date + " | " + this.isDone; + return "R" + " | " + this.type + " | " + this.date + " | " + status; } } diff --git a/src/main/java/seedu/financialplanner/reminder/ReminderList.java b/src/main/java/seedu/financialplanner/reminder/ReminderList.java index d863011c52..e54dd13153 100644 --- a/src/main/java/seedu/financialplanner/reminder/ReminderList.java +++ b/src/main/java/seedu/financialplanner/reminder/ReminderList.java @@ -27,7 +27,12 @@ public void deleteReminder(int index) { public String toString() { String result = ""; for (int i = 0; i < list.size(); i++) { - result += String.format("%d. %s\n", i + 1, list.get(i)); + if (i == list.size() - 1) { + result += String.format("%d. %s", i + 1, list.get(i)); + break; + } else { + result += String.format("%d. %s\n", i + 1, list.get(i)); + } } return result; } diff --git a/src/main/java/seedu/financialplanner/storage/LoadData.java b/src/main/java/seedu/financialplanner/storage/LoadData.java index d5b89b2c54..ed8b2a0f21 100644 --- a/src/main/java/seedu/financialplanner/storage/LoadData.java +++ b/src/main/java/seedu/financialplanner/storage/LoadData.java @@ -14,6 +14,10 @@ import seedu.financialplanner.cashflow.Income; import seedu.financialplanner.cashflow.Expense; import seedu.financialplanner.utils.Ui; +import seedu.financialplanner.goal.Goal; +import seedu.financialplanner.goal.WishList; +import seedu.financialplanner.reminder.Reminder; +import seedu.financialplanner.reminder.ReminderList; import java.io.FileNotFoundException; import java.io.FileReader; @@ -32,6 +36,8 @@ public abstract class LoadData { private static final String FILE_PATH = "data/watchlist.json"; private static final CashflowList cashflowList = CashflowList.getInstance(); private static final Ui ui = Ui.getInstance(); + private static final ReminderList reminderList = ReminderList.getInstance(); + private static final WishList wishList = WishList.getInstance(); /** @@ -61,6 +67,14 @@ public static void load(String filePath, LocalDate date) throws FinancialPlanner case "B": loadBudget(split); break; + case "R": + final Reminder reminder = getReminder(split); + reminderList.load(reminder); + break; + case "G": + final Goal goal = getGoal(split); + wishList.load(goal); + break; default: throw new FinancialPlannerException("Error loading file"); } @@ -232,6 +246,35 @@ private static Cashflow getEntry(String type, String[] split) } } + private static Reminder getReminder(String[] split) throws IllegalArgumentException, IndexOutOfBoundsException, + FinancialPlannerException { + try { + Reminder entry; + String type = split[1].trim(); + String date = split[2].trim(); + String status = split[3].trim(); + entry = new Reminder(type, date, status); + return entry; + } catch (IllegalArgumentException e) { + throw new IllegalArgumentException("Erroneous arguments detected"); + } catch (IndexOutOfBoundsException e) { + throw new FinancialPlannerException("There should be three data members for reminder"); + } + } + + private static Goal getGoal(String[] split) throws IllegalArgumentException { + try { + Goal entry; + String type = split[1].trim(); + int amount = Integer.parseInt(split[2].trim()); + String status = split[3].trim(); + entry = new Goal(type, amount, status); + return entry; + } catch (IllegalArgumentException e) { + throw new IllegalArgumentException("Erroneous arguments detected"); + } + } + private static boolean getHasRecurred(String[] split, int recur) throws IllegalArgumentException { boolean hasRecurred; if (recur != 0) { diff --git a/src/main/java/seedu/financialplanner/storage/SaveData.java b/src/main/java/seedu/financialplanner/storage/SaveData.java index 17e49e4e86..897f592432 100644 --- a/src/main/java/seedu/financialplanner/storage/SaveData.java +++ b/src/main/java/seedu/financialplanner/storage/SaveData.java @@ -3,10 +3,12 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import seedu.financialplanner.exceptions.FinancialPlannerException; +import seedu.financialplanner.goal.WishList; import seedu.financialplanner.investments.WatchList; import seedu.financialplanner.cashflow.Budget; import seedu.financialplanner.cashflow.Cashflow; import seedu.financialplanner.cashflow.CashflowList; +import seedu.financialplanner.reminder.ReminderList; import seedu.financialplanner.utils.Ui; import java.io.FileWriter; @@ -18,6 +20,8 @@ public abstract class SaveData { private static final String FILE_PATH = "data/watchlist.json"; private static final CashflowList cashflowList = CashflowList.getInstance(); + private static final ReminderList reminderList = ReminderList.getInstance(); + private static final WishList wishList = WishList.getInstance(); public static void save(String filePath) throws FinancialPlannerException { try { @@ -26,6 +30,12 @@ public static void save(String filePath) throws FinancialPlannerException { fw.write(entry.formatString() + "\n"); } fw.write(Budget.formatString() + "\n"); + for (int i = 0; i < reminderList.list.size(); i++) { + fw.write(reminderList.list.get(i).formatString() + "\n"); + } + for (int i = 0; i < wishList.list.size(); i++) { + fw.write(wishList.list.get(i).formatString() + "\n"); + } fw.close(); } catch (IOException e) { throw new FinancialPlannerException("Error saving file."); From 47187ceb82e2de382e24fb010cb25952cb6f1967 Mon Sep 17 00:00:00 2001 From: Shi Haochen <99376359+hshiah@users.noreply.github.com> Date: Fri, 3 Nov 2023 10:30:12 +0800 Subject: [PATCH 2/3] Update WishList.java --- src/main/java/seedu/financialplanner/goal/WishList.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/seedu/financialplanner/goal/WishList.java b/src/main/java/seedu/financialplanner/goal/WishList.java index b03ae4704b..612a501cbc 100644 --- a/src/main/java/seedu/financialplanner/goal/WishList.java +++ b/src/main/java/seedu/financialplanner/goal/WishList.java @@ -30,7 +30,6 @@ public String toString() { for (int i = 0; i < list.size(); i++) { if (i == list.size() - 1) { result += String.format("%d. %s", i + 1, list.get(i)); - break; } else { result += String.format("%d. %s\n", i + 1, list.get(i)); } From e249eca9e943b9164677c8351cb0e338d387f358 Mon Sep 17 00:00:00 2001 From: Shi Haochen <99376359+hshiah@users.noreply.github.com> Date: Fri, 3 Nov 2023 10:30:33 +0800 Subject: [PATCH 3/3] Update ReminderList.java --- src/main/java/seedu/financialplanner/reminder/ReminderList.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/seedu/financialplanner/reminder/ReminderList.java b/src/main/java/seedu/financialplanner/reminder/ReminderList.java index e54dd13153..94ebd7e19a 100644 --- a/src/main/java/seedu/financialplanner/reminder/ReminderList.java +++ b/src/main/java/seedu/financialplanner/reminder/ReminderList.java @@ -29,7 +29,6 @@ public String toString() { for (int i = 0; i < list.size(); i++) { if (i == list.size() - 1) { result += String.format("%d. %s", i + 1, list.get(i)); - break; } else { result += String.format("%d. %s\n", i + 1, list.get(i)); }