-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CS2113-T18-2] FinancialPlanner #17
Open
ryan1604
wants to merge
711
commits into
nus-cs2113-AY2324S1:master
Choose a base branch
from
AY2324S1-CS2113-T18-2:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 222 commits
Commits
Show all changes
711 commits
Select commit
Hold shift + click to select a range
b5ba1de
Change method name for clarity
e7355e4
Update DG with recur feature
bedd062
Add recur class and sequence diagrams
9442c88
Merge branch 'master' of https://github.com/AY2324S1-CS2113-T18-2/tp
7edf450
Merge branch 'master' into Branch-UpdateDG
4257110
Solve suggestions of Minwei
hshiah 0aa5efa
Update DG content page
8ef4691
Update UG explaining the meaning of cashflow
425cf72
Solve minor errors.
hshiah 1642706
Merge pull request #134 from hshiah/hshiah
hshiah 6ac95c6
Add some fix to DG and UG
wwweert123 59beb3d
Merge branch 'master' into VisDG
wwweert123 f2077fc
Update DG
53cc8ca
Fix typo to be in camelCase
be61c28
Merge branch 'master' of https://github.com/AY2324S1-CS2113-T18-2/tp
8e6bc95
Merge branch 'master' into Branch-UpdateDG
35f10a3
Merge pull request #135 from NeoMinWei/Branch-UpdateDG
NeoMinWei 660f302
Merge branch 'master' of https://github.com/AY2324S1-CS2113-T18-2/tp
c9b08fc
FIx formatting error in UG
3813917
Merge pull request #140 from NeoMinWei/Branch-UGquickfix
NeoMinWei 5d2940d
Merge branch 'master' of https://github.com/AY2324S1-CS2113-T18-2/tp
d90ccc5
Finish all user stories for v2.0
hshiah 2ecb578
Add help command
YFshadaow 3f80f21
Update EXPECTED.TXT for UI testing
YFshadaow 27418e4
Update src/main/java/seedu/financialplanner/commands/MarkGoalCommand.…
hshiah 410558c
Update src/main/java/seedu/financialplanner/commands/MarkGoalCommand.…
hshiah d9293b5
Update ExpenseType.java
hshiah 01e764d
Update MarkGoalCommand.java
hshiah a026d6c
Update src/main/java/seedu/financialplanner/commands/DeleteGoalComman…
hshiah 0544e3f
Merge pull request #143 from hshiah/temp
hshiah 62ab3bf
Merge pull request #141 from wwweert123/VisDG
wwweert123 ac5f45a
Merge branch 'master' of https://github.com/AY2324S1-CS2113-T18-2/tp …
YFshadaow 3eab7c3
Resolve merge conflicts
YFshadaow c8298c3
Merge pull request #142 from YFshadaow/help-command
YFshadaow 810c718
Fix DG sequence diagram for cat and vis
wwweert123 4392054
Merge branch 'master' of https://github.com/AY2324S1-CS2113-T18-2/tp
3590c87
Update UG. Fix some minor errors of reminder and goal. Update the sav…
hshiah 2447cba
Fix code according to DG
wwweert123 47187ce
Update WishList.java
hshiah e249eca
Update ReminderList.java
hshiah 3f4327a
Merge pull request #151 from hshiah/hshiah
hshiah d95af1b
Merge branch 'master' into VisDG
wwweert123 ad69fe0
Merge pull request #150 from wwweert123/VisDG
wwweert123 2815bb5
Remove long method parameters in recur sequence and class diagrams
03c556b
Resolve spacing issues in headers
9abcc2f
Add description for the types accepted in add income and expense
c27e5dd
Fix bugs
ryan1604 26bbcd4
Add maximum/minimum value exception
fd935ef
Add trimming of arguments from input
b75a589
Add listing of total balance in list command and removing of extra sp…
6611146
Update diagrams, DG and UG
ryan1604 51480db
Add change for loading watchlist with more than 5 stocks, initallize …
wwweert123 ed086fe
Merge branch 'master' into FixBugsEnhanceDGUG
wwweert123 e0869ff
Update UG
ryan1604 1c50478
Update test file
ryan1604 0a1278b
Create new constructor for adding base stocks
wwweert123 9430c21
Update reset budget diagram
ryan1604 8ea9b49
Fix typo
ryan1604 2902393
Add mechanism to clean up watchlist as much as possible to remove non…
wwweert123 f008034
Add to UG to warn user
wwweert123 1f63e8d
Add check for whether null stocks are passed before printing
wwweert123 466e04d
Add saving of watchlist after watchlist command
wwweert123 8b56635
Add attempt of removing of both normal stock and its uppercase form
wwweert123 4270383
Add details to UG
wwweert123 6edb7ea
Add printing of acknowledgement to APIs
wwweert123 0146afb
Add PPP to be completed
ryan1604 d7e4477
Add instructions for adding stock using JSON
wwweert123 c1af3ef
Add additonal checks for adding stock and handle exception for stock …
wwweert123 52300e6
Add to UG q and A
wwweert123 1bafe66
Fix bug
98daeac
Fix checkstyle
wwweert123 11d1174
Fix code according to reviewer
wwweert123 8d7db09
Fix typo
wwweert123 f9593b3
Add return in Budget
ryan1604 6073833
Merge pull request #191 from ryan1604/branch-bugfix
ryan1604 e6cc5c4
Merge branch 'master' of https://github.com/AY2324S1-CS2113-T18-2/tp
a8d8d26
Merge branch 'master' into Branch-PEBugFix
058defc
Make changes according to PR reviews
07b02e6
Add trimming for commands
wwweert123 265b96c
Add padding to watchlist command
wwweert123 4927653
Add on to UG
wwweert123 12a0724
Add PPP
wwweert123 5865c8e
Merge branch 'master' into FixBugsEnhanceDGUG
wwweert123 f988a32
Change colour of message printed
wwweert123 51f8f51
Merge pull request #193 from wwweert123/FixBugsEnhanceDGUG
wwweert123 5a5dc49
Merge branch 'master' of https://github.com/AY2324S1-CS2113-T18-2/tp
13f5f72
Merge branch 'master' into Branch-PEBugFix
03c0c58
Add PPP
a93e83d
Rename PPP file to be in lower case
7694949
Merge pull request #192 from NeoMinWei/Branch-PEBugFix
NeoMinWei f07b5b0
Merge branch 'master' of https://github.com/AY2324S1-CS2113-T18-2/tp
24f5843
Remove activation bars for ref sd
ryan1604 3a11b37
Merge branch 'master' into branch-bugfix
ryan1604 08d0112
Update overview command
ryan1604 9a4f943
Add JUnit testing for DeleteCashflowCommand
bd8a8bf
Add JUnit test for Cashflow
2df3f93
Update JUnit tests in CashflowList and AddCashflowCommand to include …
d9bd60d
Add fullstops to exception messages
72a16ae
Fix JUnit
3a0fb32
Rename method to follow camelCase
f52f1e1
Add javadoc comments
52da987
Update text ui test
e2ebbe9
Add fullstop to error message
c3c411b
Refactor help command structure:
YFshadaow 932b6e9
Update DG and UG
ryan1604 700392d
Fix bug
ryan1604 578564c
Update Architecture Diagram and fix typo
ryan1604 878d782
Merge pull request #194 from NeoMinWei/Branch-FinalJunit
NeoMinWei 727ab4b
Merge branch 'master' of https://github.com/AY2324S1-CS2113-T18-2/tp
fba7732
Merge pull request #196 from ryan1604/branch-bugfix
ryan1604 2f2a764
Add javadoc to classes and methods
wwweert123 8660d42
Add DG value proposition and user profile
wwweert123 e3d3d00
Add user stories
wwweert123 1cbae2b
Add term to glossary
wwweert123 e901e67
Add checkstyle fixes
wwweert123 dc31f33
Add simple manual testing and fix bugs
wwweert123 cae5827
Update contributions for PPP
wwweert123 a11d406
Merge pull request #197 from wwweert123/javadocNDG
wwweert123 abf2f8c
Merge branch 'master' of https://github.com/YFshadaow/tp into help-co…
YFshadaow c3ed577
Resolve merge conflicts
YFshadaow 2bf3be5
Finish all command usage and example usage. Add example usage to help…
YFshadaow c936fb5
Remove comment from build.gradle
YFshadaow 49df5b0
Fix bugs
hshiah 5d6c505
Add find and help commands to user guide
YFshadaow d579e32
Fix spacing in BudgetCommand.java
YFshadaow 0543ea4
Fix usage of add cashflow command
YFshadaow 56a6742
Fix incorrect exception message due to invocation target exception ca…
YFshadaow 2a25f48
Enhancement of reminder
hshiah c9cc538
Add list command to UG
3684545
Fix date format
hshiah b68d1c2
Fix typo
ce4b754
Fix incorrect directory in UG
8f06d05
Merge pull request #200 from YFshadaow/help-command-refactor-and-bug-…
YFshadaow cac53ac
Merge branch 'master' into hshiah
hshiah 320aa07
Merge pull request #198 from hshiah/hshiah
hshiah 0efce8f
Update readme and aboutus
ryan1604 cd6c82e
Fix bugs of loading and saving reminder
hshiah 6f23dec
Fix coding style
hshiah e0b2656
Merge pull request #203 from hshiah/hshiah
hshiah 45e97d6
Merge pull request #202 from ryan1604/branch-ug
ryan1604 1059aa1
Fix mistakes
wwweert123 69016f4
Merge pull request #201 from NeoMinWei/Branch-FinalUG
ryan1604 346f3c7
Solve slf4j binding warning
YFshadaow e0801c3
Merge pull request #204 from YFshadaow/fix-logger-binding
YFshadaow 593c2db
Fix UG and DG
ryan1604 aba804b
Merge pull request #205 from ryan1604/branch-bugfix
ryan1604 3c5ddee
Fix bugs
hshiah 4b8495e
Fix addstock
wwweert123 19fbd5c
Merge pull request #207 from wwweert123/javadocNDG
wwweert123 3eda51d
Update UG
hshiah 21ac550
Merge pull request #206 from hshiah/hshiah
hshiah eb6d563
Add mechanism to tell user that he has input the values wrongly in js…
wwweert123 3c77204
Add hashing of values to ensure nobody tampers with the json file
wwweert123 97d75b5
Update UG
wwweert123 1324840
Merge branch 'master' of https://github.com/AY2324S1-CS2113-T18-2/tp
fab38b1
Fix date format in reminder
07636fc
Add exception thrown when impossible dates are detected
a207e78
Convert parameter to lowercase for categorizer and visualizer
wwweert123 8bde6d4
Change load watchlist to take take file path as parameter
wwweert123 4f29a53
Convert to uppercase when passing stock code into Stock constructor
wwweert123 b83a06c
Add junit test for watchlist
wwweert123 31126ff
Add junit test for categorizer and visualizer
wwweert123 3a03ae7
Add return value for javadoc
wwweert123 51cedca
Fix typo
wwweert123 2bdb914
Update PPP
63c26c2
Merge branch 'master' into javadocNDG
wwweert123 997c841
Fix bug
f836550
Fix checkstyle
wwweert123 5a83f4f
Add new line
wwweert123 accfb52
Disable test on linx
wwweert123 76fe341
Merge pull request #208 from wwweert123/javadocNDG
wwweert123 2ca87af
Update UG
ryan1604 9192e6c
Add mechanism to disallow adding stock with other fields
wwweert123 83db9ed
Add setting of fetch time even for invalid stocks
wwweert123 2a407e4
Reorder UG
ryan1604 26ea23a
Fix displaying of wrong balance when recurring cashflows are added
38075f2
Add error handling for recur value exceeding maximum int value
95babe9
Update user guide
2afa997
Add error handling for index exceeding max int value
7b714b0
Update Junit
efabe5a
Delete note for income type in UG
ryan1604 94e1308
Last Changes
wwweert123 4b44100
Fix Vis diagrams
wwweert123 fadf088
Add watchlist feature to DG
wwweert123 3612cc8
Add to table of contents
wwweert123 614e9c9
Merge pull request #210 from ryan1604/branch-bugfix
ryan1604 36e7556
Update PPP
wwweert123 e19808b
Fix bugs
hshiah 86e7b72
Fix checkstyle
hshiah 579a5e1
Update Diagrams
wwweert123 ff1bffa
Update javadoc
hshiah 63f5765
Fix checkstyle
hshiah 1bdd7d3
Merge pull request #209 from NeoMinWei/Branch-ReminderDate
ryan1604 d8b6e07
Add activation bars to sequence diagrams
f82fcc7
Merge branch 'master' of https://github.com/AY2324S1-CS2113-T18-2/tp …
7a20e0f
Fix table of content
wwweert123 3737520
Add activation diagram
wwweert123 2e591a2
Change back
wwweert123 d6dc02d
Merge pull request #211 from wwweert123/javadocNDG
wwweert123 e7c0591
Add manual testing
wwweert123 70b7704
Merge branch 'master' of https://github.com/AY2324S1-CS2113-T18-2/tp …
587ce36
Fix typo
wwweert123 941be64
Merge pull request #214 from wwweert123/javadocNDG
wwweert123 6721762
Add manual testing
85c469f
Update manual testing
fad742f
Merge branch 'master' of https://github.com/AY2324S1-CS2113-T18-2/tp …
0d03642
Add manual testing
ryan1604 889370d
Finished test and fix bugs.
hshiah 55ae6a6
Merge pull request #213 from NeoMinWei/Branch-ReminderDate
NeoMinWei c417ab5
Merge branch 'master' into branch-bugfix
ryan1604 65663a8
Merge pull request #215 from ryan1604/branch-bugfix
ryan1604 c1e591c
Final update
hshiah 558f765
Merge branch 'master' into hshiah
hshiah 7cc98dc
Update SetGoalCommandTest.java
hshiah 57b5961
Update AddReminderCommandTest.java
hshiah ff4a734
Update ReminderListCommand.java
hshiah 829d36a
Merge pull request #212 from hshiah/hshiah
hshiah 7b3be7b
Fix bug in UGDG
ryan1604 ea272b6
Update PPP
ryan1604 730afd0
Fix broken link
wwweert123 8cc3fec
Add fix that you can only add stocks in capital letters using file
wwweert123 9bd2f73
Merge pull request #216 from ryan1604/branch-bugfix
ryan1604 d4d6562
Merge pull request #217 from wwweert123/changesDG
wwweert123 875b0ab
Fix broken link
wwweert123 1f3e3e5
Merge pull request #218 from wwweert123/changesDG
wwweert123 1852642
Add about us
wwweert123 fbeda55
Merge pull request #219 from wwweert123/changesDG
wwweert123 9b7a4b7
Merge branch 'master' of https://github.com/AY2324S1-CS2113-T18-2/tp
a7bbd83
Fix DG and UG
wwweert123 6f57dc6
Fix
wwweert123 1e59dff
fix typo
wwweert123 4a5e4e4
Merge pull request #220 from wwweert123/changesDG
wwweert123 6bff288
Fix bug in UG
ryan1604 2a15144
Merge pull request #221 from ryan1604/branch-bugfix
ryan1604 3a324b7
Add fix
wwweert123 99b8c54
Merge branch 'master' of https://github.com/AY2324S1-CS2113-T18-2/tp
1c915c4
Merge pull request #222 from wwweert123/changesDG
wwweert123 e4f7d1e
Update add cashflow explanations
0b7dbb5
Merge pull request #223 from NeoMinWei/Branch-DGQuickFix
NeoMinWei 9c15ad8
Fix bug
ryan1604 bdb553a
Fix bug
ryan1604 30ef4ff
Merge pull request #224 from ryan1604/branch-bugfix
ryan1604 c4a964a
Final Final FInal Final changes
wwweert123 2de04b7
Merge pull request #225 from wwweert123/changesDG
wwweert123 80da84b
Add project portfolio page
YFshadaow e97054c
Merge pull request #226 from YFshadaow/yfshadaow-project-portfolio-page
YFshadaow be44706
Update aboutus page
YFshadaow 708646a
Merge pull request #227 from YFshadaow/yfshadaow-project-portfolio-page
YFshadaow 878b5ac
Remove the non-existing John Doe from AboutUs.md
YFshadaow 3b2bd80
Merge pull request #228 from YFshadaow/yfshadaow-project-portfolio-page
YFshadaow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ bin/ | |
|
||
/text-ui-test/ACTUAL.TXT | ||
text-ui-test/EXPECTED-UNIX.TXT | ||
data/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
# About us | ||
|
||
Display | Name | Github Profile | Portfolio | ||
--------|:----:|:--------------:|:---------: | ||
![](https://via.placeholder.com/100.png?text=Photo) | John Doe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) | ||
![](https://via.placeholder.com/100.png?text=Photo) | Don Joe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) | ||
![](https://via.placeholder.com/100.png?text=Photo) | Ron John | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) | ||
![](https://via.placeholder.com/100.png?text=Photo) | John Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) | ||
![](https://via.placeholder.com/100.png?text=Photo) | Don Roe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) | ||
Display | Name | Github Profile | Portfolio | ||
--------|:-----------:|:--------------:|:---------: | ||
![](https://via.placeholder.com/100.png?text=Photo) | John Doe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) | ||
![](https://via.placeholder.com/100.png?text=Photo) | Don Joe | [Github](https://github.com/) | [Portfolio](docs/team/johndoe.md) | ||
![](https://via.placeholder.com/100.png?text=Photo) | Ryan Chua | [Github](https://github.com/ryan1604) | [Portfolio](docs/team/ryanchua.md) | ||
![](https://via.placeholder.com/100.png?text=Photo) | Neo Min Wei | [Github](https://github.com/NeoMinWei) | [Portfolio](docs/team/NeoMinWei.md) | ||
![](https://via.placeholder.com/100.png?text=Photo) | Frederick | [Github](https://github.com/) | [Portfolio](docs/team/frederick.md) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
remote_theme: pages-themes/[email protected] | ||
plugins: | ||
- jekyll-remote-theme # add this line to the plugins list if you already have one |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# John Doe - Project Portfolio Page | ||
# Neo Min Wei - Project Portfolio Page | ||
|
||
## Overview | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
I am Frederick | ||
|
||
Hello | ||
|
||
I am from this team! |
Empty file.
This file was deleted.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
src/main/java/seedu/financialplanner/FinancialPlanner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package seedu.financialplanner; | ||
|
||
import seedu.financialplanner.commands.AbstractCommand; | ||
import seedu.financialplanner.commands.ExitCommand; | ||
import seedu.financialplanner.exceptions.FinancialPlannerException; | ||
import seedu.financialplanner.investments.WatchList; | ||
import seedu.financialplanner.list.CashflowList; | ||
import seedu.financialplanner.storage.Storage; | ||
import seedu.financialplanner.utils.Parser; | ||
import seedu.financialplanner.utils.Ui; | ||
|
||
public class FinancialPlanner { | ||
|
||
private static final String FILE_PATH = "data/data.txt"; | ||
private final Storage storage = Storage.INSTANCE; | ||
private final Ui ui = Ui.INSTANCE; | ||
private final WatchList watchList = WatchList.INSTANCE; | ||
private final CashflowList cashflowList = CashflowList.INSTANCE; | ||
|
||
private FinancialPlanner() { | ||
} | ||
|
||
public static void main(String[] args) { | ||
new FinancialPlanner().run(); | ||
} | ||
|
||
public void run() { | ||
try { | ||
storage.load(cashflowList, ui, FILE_PATH); | ||
} catch (FinancialPlannerException e) { | ||
ui.showMessage(e.getMessage()); | ||
return; | ||
} | ||
|
||
FinancialPlannerLogger.initialise(); | ||
ui.welcomeMessage(); | ||
String input; | ||
AbstractCommand command = null; | ||
|
||
while (!(command instanceof ExitCommand)) { | ||
input = ui.input(); | ||
try { | ||
command = Parser.parseCommand(input); | ||
command.execute(); | ||
} catch (Exception e) { | ||
ui.showMessage(e.getMessage()); | ||
} | ||
} | ||
save(); | ||
ui.exitMessage(); | ||
} | ||
|
||
public void save() { | ||
try { | ||
storage.save(cashflowList, FILE_PATH); | ||
} catch (FinancialPlannerException e) { | ||
ui.showMessage(e.getMessage()); | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/seedu/financialplanner/FinancialPlannerLogger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package seedu.financialplanner; | ||
|
||
import java.util.logging.FileHandler; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
import java.util.logging.SimpleFormatter; | ||
import java.util.logging.LogManager; | ||
|
||
public class FinancialPlannerLogger { | ||
private static Logger logger = Logger.getLogger("Financial Planner Logger"); | ||
|
||
public static void initialise() { | ||
try { | ||
FileHandler fh = new FileHandler("data/logger.log"); | ||
LogManager.getLogManager().reset(); | ||
logger.addHandler(fh); | ||
fh.setFormatter(new SimpleFormatter()); | ||
logger.log(Level.INFO, "Logger initialised"); | ||
} catch (Exception e) { | ||
logger.log(Level.SEVERE, e.getMessage()); | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/seedu/financialplanner/commands/AbstractCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package seedu.financialplanner.commands; | ||
|
||
public abstract class AbstractCommand { | ||
public abstract void execute() throws Exception; | ||
} |
112 changes: 112 additions & 0 deletions
112
src/main/java/seedu/financialplanner/commands/AddCashflowCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package seedu.financialplanner.commands; | ||
|
||
import seedu.financialplanner.enumerations.CashflowCategory; | ||
import seedu.financialplanner.list.Budget; | ||
import seedu.financialplanner.list.Cashflow; | ||
import seedu.financialplanner.list.CashflowList; | ||
import seedu.financialplanner.utils.Ui; | ||
|
||
import java.util.ArrayList; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
|
||
public class AddCashflowCommand extends AbstractCommand { | ||
|
||
private static Logger logger = Logger.getLogger("Financial Planner Logger"); | ||
protected double amount; | ||
protected CashflowCategory category; | ||
protected String type; | ||
protected int recur = 0; | ||
|
||
public AddCashflowCommand(RawCommand rawCommand) throws IllegalArgumentException { | ||
String typeString = String.join(" ", rawCommand.args); | ||
try { | ||
logger.log(Level.INFO, "Parsing CashflowCategory"); | ||
category = CashflowCategory.valueOf(typeString.toUpperCase()); | ||
} catch (IllegalArgumentException e) { | ||
logger.log(Level.WARNING, "Invalid arguments for CashflowCategory"); | ||
throw new IllegalArgumentException("Entry must be either income or expense"); | ||
} | ||
|
||
if (!rawCommand.extraArgs.containsKey("a")) { | ||
logger.log(Level.WARNING, "Missing arguments for amount"); | ||
throw new IllegalArgumentException("Entry must have an amount"); | ||
} | ||
try { | ||
logger.log(Level.INFO, "Parsing amount as double"); | ||
amount = Double.parseDouble(rawCommand.extraArgs.get("a")); | ||
} catch (IllegalArgumentException e) { | ||
logger.log(Level.WARNING, "Invalid arguments for amount"); | ||
throw new IllegalArgumentException("Amount must be a number"); | ||
} | ||
if (amount < 0) { | ||
logger.log(Level.WARNING, "Invalid value for amount"); | ||
throw new IllegalArgumentException("Amount cannot be negative"); | ||
} | ||
rawCommand.extraArgs.remove("a"); | ||
|
||
if (!rawCommand.extraArgs.containsKey("t")) { | ||
logger.log(Level.WARNING, "Missing arguments for type"); | ||
throw new IllegalArgumentException("Entry must have a type"); | ||
} | ||
type = rawCommand.extraArgs.get("t"); | ||
if (type.isBlank()) { | ||
logger.log(Level.WARNING, "Invalid arguments for type"); | ||
throw new IllegalArgumentException("Type cannot be left empty"); | ||
} | ||
rawCommand.extraArgs.remove("t"); | ||
|
||
if (rawCommand.extraArgs.containsKey("r")) { | ||
try { | ||
logger.log(Level.INFO, "Parsing recur as integer"); | ||
recur = Integer.parseInt(rawCommand.extraArgs.get("r")); | ||
} catch (IllegalArgumentException e) { | ||
logger.log(Level.WARNING, "Invalid arguments for recur"); | ||
throw new IllegalArgumentException("Recurrence must be an integer"); | ||
} | ||
rawCommand.extraArgs.remove("r"); | ||
} | ||
if (recur < 0) { | ||
logger.log(Level.WARNING, "Invalid value for recur"); | ||
throw new IllegalArgumentException("Recurring value cannot be negative"); | ||
} | ||
|
||
if (!rawCommand.extraArgs.isEmpty()) { | ||
String unknownExtraArgument = new ArrayList<>(rawCommand.extraArgs.keySet()).get(0); | ||
logger.log(Level.WARNING, "Invalid extra arguments found"); | ||
throw new IllegalArgumentException(String.format("Unknown extra argument: %s", unknownExtraArgument)); | ||
} | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
assert category.equals(CashflowCategory.INCOME) || category.equals(CashflowCategory.EXPENSE); | ||
assert recur >= 0; | ||
assert amount >= 0; | ||
assert type != null; | ||
|
||
switch (category) { | ||
case INCOME: | ||
CashflowList.INSTANCE.addIncome(amount, type, recur); | ||
break; | ||
case EXPENSE: | ||
CashflowList list = CashflowList.INSTANCE; | ||
list.addExpense(amount, type, recur); | ||
if (Budget.hasBudget()) { | ||
deductFromBudget(list.list.get(list.list.size() - 1)); | ||
} | ||
break; | ||
default: | ||
logger.log(Level.SEVERE, "Unreachable default case reached"); | ||
Ui.INSTANCE.showMessage("Unidentified entry."); | ||
break; | ||
} | ||
} | ||
|
||
private static void deductFromBudget(Cashflow entry) { | ||
double expenseAmount = entry.getAmount(); | ||
Budget.deduct(expenseAmount); | ||
Ui.INSTANCE.printBudgetAfterDeduction(); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/seedu/financialplanner/commands/AddReminderCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package seedu.financialplanner.commands; | ||
import seedu.financialplanner.reminder.ReminderList; | ||
import seedu.financialplanner.reminder.Reminder; | ||
import seedu.financialplanner.utils.Ui; | ||
public class AddReminderCommand extends AbstractCommand{ | ||
private final String type; | ||
private final String date; | ||
|
||
public AddReminderCommand(RawCommand rawCommand) throws IllegalArgumentException { | ||
String typeString = String.join(" ", rawCommand.args); | ||
if(!rawCommand.extraArgs.containsKey("t")){ | ||
throw new IllegalArgumentException("Reminder must have a type"); | ||
} | ||
type = rawCommand.extraArgs.get("t"); | ||
rawCommand.extraArgs.remove("t"); | ||
if(!rawCommand.extraArgs.containsKey("d")){ | ||
throw new IllegalArgumentException("Reminder must have a date"); | ||
} | ||
date = rawCommand.extraArgs.get("d"); | ||
rawCommand.extraArgs.remove("d"); | ||
if(!rawCommand.extraArgs.isEmpty()){ | ||
String unknownExtraArgument = new java.util.ArrayList<>(rawCommand.extraArgs.keySet()).get(0); | ||
throw new IllegalArgumentException(String.format("Unknown extra argument: %s", unknownExtraArgument)); | ||
} | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
ReminderList.INSTANCE.list.add(new Reminder(type, date)); | ||
Ui.INSTANCE.showMessage("Reminder added!"); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/seedu/financialplanner/commands/AddStockCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package seedu.financialplanner.commands; | ||
|
||
import seedu.financialplanner.exceptions.FinancialPlannerException; | ||
import seedu.financialplanner.investments.WatchList; | ||
import seedu.financialplanner.utils.Ui; | ||
|
||
import java.util.ArrayList; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
public class AddStockCommand extends AbstractCommand { | ||
private static final Logger logger = Logger.getLogger("Financial Planner Logger"); | ||
private final String stockCode; | ||
|
||
public AddStockCommand(RawCommand rawCommand) throws IllegalArgumentException { | ||
if (!rawCommand.extraArgs.containsKey("s")) { | ||
throw new IllegalArgumentException("Stock code cannot be empty"); | ||
} | ||
|
||
logger.log(Level.INFO, "Parsing stockcode from input"); | ||
stockCode = rawCommand.extraArgs.get("s"); | ||
|
||
rawCommand.extraArgs.remove("s"); | ||
if (!rawCommand.extraArgs.isEmpty()) { | ||
String unknownExtraArgument = new ArrayList<>(rawCommand.extraArgs.keySet()).get(0); | ||
logger.log(Level.WARNING, "Invalid extra arguments found"); | ||
throw new IllegalArgumentException(String.format("Unknown extra argument: %s", unknownExtraArgument)); | ||
} | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
Ui ui = Ui.INSTANCE; | ||
WatchList watchList = WatchList.INSTANCE; | ||
String stockName; | ||
|
||
logger.log(Level.INFO, "adding stock to watchlist"); | ||
try { | ||
stockName = watchList.addStock(stockCode); | ||
assert stockName != null; | ||
ui.printAddStock(stockName); | ||
} catch (FinancialPlannerException e) { | ||
logger.log(Level.SEVERE, "Error adding stock to watchlist"); | ||
System.out.println(e.getMessage()); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to put abstract in the class name