Overview
MoneyGoWhere is a desktop application which aims to help users keep track of their spending, as well as necessary information such as date, cost and name. Users can also set a budget, set reminders as well as get stats of the spending.
MoneyGoWhere has a Command Line Interface(CLI) for user to interact with as well as a Graphical User Interface(GUI) built using JavaFx. It is written in Java, and has about 15 kLoC.
My Role
I was a developer and was tasked to implement the Budget
feature of the program, as well as implemented the ability for users to press the up and down key to traverse their command history. I have also made notable contributions to the User Guide and Developer Guide.
Summary of contributions
This section shows my contributions to the team project.
-
Major enhancement: Implemented the
Budget
feature of MoneyGoWhere-
What it does: Allows users to set a monthly budget.
-
Justification: This feature is a core component in the program. One of the key features of the program is to show the user whether or not the user spends within budget.
-
Highlights: This enhancement requires an in-depth of the software architecture. It affects other commands as it affected by certain commands.
-
-
Minor enhancement: Implemented
showbudget
command to show users their budget as well as sum of spending in the month set. -
Minor enhancement: Implemented the ability for users to navigate through previous commands using up/down keys.
-
Code contributed: [Collated code]
-
Other contributions:
Contributions to the User Guide
The following sections showcase my contributions to the User Guide, which demonstrates my documentation skill to target end-user effectively. |
Setting monthly budget : budget
Sets a budget for the current month in the currency set.
Format: budget MONTHLY_BUDGET
Using the budget command will overwrite the currently set budget.
|
Example:
-
budget 5000
Sets a budget of $5000
for this month
Expected Output:
The budget for the current month is changed to the set amount.
Showing current budget : showbudget
Shows the current monthly budget, total spending and remaining budget in Singapore Dollars.
Format: showbudget
Expected Output:
The budget for the current month along with the total spending in the month as well as remaining budget is shown.
Going through your command history
Similar to a typical command line interface (CLI), the user may press the up and down key to go through the previous user input history, and display it in the command box. Pressing the up key would go back to the earlier user input command. Whereas pressing the down key would move towards the most recent user input key.
If the user is at the most recent, or the earliest user inputted command, then press the up and down key respectively, no text will be displayed. |
Contributions to the Developer Guide
The following sections showcase my contributions to the Developer Guide, which demonstrates my documentation skill from a technical perspective. |
Budget feature
The Budget
component has two core features:
-
Allowing the user to set the monthly budget
-
Calculating the remanding budget after all the spending in the same month.
The budget component allows the users to modify the current monthly budget budget AMOUNT
command, where AMOUNT is a
double representing the desired monthly budget. The amount cannot exceed 1,000,000,000 Singapore dollars.
For example budget 10000
sets the current monthly budget to 10000.
The budget amount must be a positive number no greater than 1000000000 Singapore dollars and must only have two digits after the decimal point. |
The second functionality is done automatically by the program, which finds the total spending in the month and reduces the sum from the budget.
Current Implementation
The current Budget
component keeps track of three variables:
-
The monthly budget amount.
-
The month the budget is set.
-
The sum of all spending in the month.
The budget amount and the month the budget is set are saved in the save file, whereas the sum is not. Upon initialization, if a save file is found it will automatically set the monthly budget based on the save file’s options. Once the save file is loaded, the program will check today’s month. If the month has changed, the budget’s set month will change to the current month, and the budget amount will carry over. Once the month has been set, it will go through all spending available and sum up all the spending that are in the set month. It will then keep track of this sum.
Once done initializing, users can set a new monthly budget by executing the budget
command.
The sequence diagram below demonstrates how the budget command is executed:
The figure above shows the sequence of events that occur to set the monthly budget:
-
User first enters "budget 100000".
-
The
LogicManager
receives the user input and passes it to theSpendingBookParser
, which passes it toBudgeCommandParser
to parse the user input. -
If the user input is valid, a
BudgetCommand
is then created. -
The
BudgetCommand
is then executed. -
The Budget in Model then set to the new amount.
Budget also keeps track of the sum of all spending in order to show the user how much budget the user has left.
Initially, it has totaled up all spending in the save file, and then the value is modified when the add
, delete
and edit
commands are called.
The following sequence diagram demonstrates how Budget modifies its value when the add
command is used:
Budget
when add
command is calledThe diagram above shows what happens when an addCommand
is being executed. It focuses only on the components that affect Budget
.
When adding a new Spending
the following steps happen:
-
The new
Spending
is passed to Model to be added. -
The new
Spending
is then passed toSpendingBook
to be added. -
SpendingBook passes the
Spending
toBudget
. -
Budget
checks whether theSpending
is in the same month as it is set or not. -
If they are in the same month, the sum of
Budget
is updated accordingly.
The same applies to delete
commands, instead of adding to the sum, it is subtracting from the sum.
As well as edit
command, which utilizes both add
and delete
.
Design Consideration
Aspect | Alternative 1 | Alternative 2 |
---|---|---|
Method to calculate sum of spending |
Keep track of the sum and modifies the sum when |
Calculate from |
A combination of the two was chosen. During the initialization phase, we read through
all spending available, but we handle add
, delete
and edit
commands using option 1.
Command History Feature
Similar to a typical CLI, the up and down key allows the users to cycle through their previous commands.
Implementation
The up and down key mechanism is facilitated by the logic
component of MoneyGoWhere.
Whenever a user inputs a command, it is stored internally in a list in CommandHistory
component of Storage
.
CommandHistory
has an internal index to keep track of its current position in the list.
Additionally, it implements the following operations:
-
Logic#getNextCommand()
— Retrieves the next user input command with respect to the current index. -
Logic#getPrevCommand()
— Retrieves the previous user input command with respect to the current index.
The index is initially set to -1, to indicate that there has been no user input. Whenever a user inputs a command, the command is stored at the end of the list and the index is set to the size of the list, to indicate that there are no commands beyond after this point.
Calling getPrevCommand()
will cause the index to decrement by 1 and show the user input command stored at that index.
When the index is currently 0, or the first user input, pressing the up key will cause the index to result in -1.
This returns the empty string, since there are no commands before this point. Any further up key press will have the same
outcome, but the index will stay at negative one.
Calling getNextCommand()
will cause the index to increment by 1 and the user input at that index will be returned.
If the index is currently the last possible value, the last user input, pressing the down key will cause the
index to increment by 1, which is outside the list, the empty string will be returned. Any further down key press
will have the same outcome but the index will stay at the list size or one after the last possible index.
The following sequence diagram shows how the up/down key mechanism works:
getNextCommand()
getPrevCommand() works the same way as the the sequence diagram above for getNextCommand() .
The only difference is which commands get returned.
|
The following steps explain the sequence diagram:
-
The user presses the
down
key. -
LogicManager
callsStorageManager#getNextCommand()
. -
StorageManager#getNextCommand()
callsCommandHistory#getNextCommand()
-
CommandHistory
returns the next user input. -
The returned command is then showed to the user in the
CommandBox
.
To summarize what determines the output when the user presses the down key:
getNextCommand()
The following steps explain the activity diagram:
-
The user presses the
down
key. -
CommandHistory
will increment its index. -
If the index is not out of bounds, the user input at the index will be returned
-
Else, the index is set to the size of the list, and an empty string is returned.
The sequence diagram and activity diagram for getPrevCommand()
are similar to the sequence and activity diagram of getNextCommand()
as shown above.
The only difference is whether it returns the next command or the previous command.