Skip to content

Commit

Permalink
Merge pull request #151 from hshiah/hshiah
Browse files Browse the repository at this point in the history
Update UG and storage
  • Loading branch information
hshiah authored Nov 3, 2023
2 parents c8298c3 + e249eca commit 3f4327a
Show file tree
Hide file tree
Showing 7 changed files with 242 additions and 6 deletions.
158 changes: 157 additions & 1 deletion docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/seedu/financialplanner/goal/Goal.java
Original file line number Diff line number Diff line change
Expand Up @@ -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: " +
Expand All @@ -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;
}
}
6 changes: 5 additions & 1 deletion src/main/java/seedu/financialplanner/goal/WishList.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ 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));
} else {
result += String.format("%d. %s\n", i + 1, list.get(i));
}
}
return result;
}
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/seedu/financialplanner/reminder/Reminder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ 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));
} else {
result += String.format("%d. %s\n", i + 1, list.get(i));
}
}
return result;
}
Expand Down
43 changes: 43 additions & 0 deletions src/main/java/seedu/financialplanner/storage/LoadData.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();


/**
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/seedu/financialplanner/storage/SaveData.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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.");
Expand Down

0 comments on commit 3f4327a

Please sign in to comment.