Skip to content

Commit

Permalink
Merge pull request #247 from Chinorea/branch-PE-D-Issues
Browse files Browse the repository at this point in the history
Update Naming Convention for Edit feature
  • Loading branch information
Chinorea authored Nov 12, 2024
2 parents bf2ee6b + baaa8c9 commit 1ce4965
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 23 deletions.
12 changes: 6 additions & 6 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,12 @@ Expected Usage of Feature:
![ListExpense_ExpectedOutput.png](images/ListExpenses_ExpectedOutput.png)
![ListExpenseWithFilter_ExpectedOutput.png](images/ListExpensesWithFilter_ExpectedOutput.png)

#### 4. Edit pre-existing expenses: `edit expenses`
#### 4. Edit pre-existing expenses: `edit expense`
Edit a pre-existing expense entry details. Users can edit the category, amount and date of the expense field. 2 sets of
input will be required from the user.

Format:
1. `edit expenses INDEX`
1. `edit expense INDEX`
2. `[a/AMOUNT c/CATEGORY d/DATE]`

* The `INDEX` is the index of the desired expenses based on list expense that the user wants to edit.
Expand All @@ -231,7 +231,7 @@ Note:
* For the second input, at least one of the field must be provided, else it returns back to main menu.

Example of usage:
1. `edit expenses 3`
1. `edit expense 3`
2. `a/100 c/food d/15/10/2024`

Expected Usage of Feature:
Expand Down Expand Up @@ -346,12 +346,12 @@ Expected Usage of Feature:

![DeleteIncome_Expected_Output.png](images/DeleteIncome_Expected_Output.png)

#### 3. Edit pre-existing incomes: `edit incomes`
#### 3. Edit pre-existing incomes: `edit income`
Edit a pre-existing income entry details. Users can edit the amount and date of the expense field. 2 sets of input
will be required from the user.

Format:
1. `edit incomes INDEX`
1. `edit income INDEX`
2. `[a/AMOUNT d/DATE]`

* The `INDEX` is the index of the desired expenses based on list income that the user wants to edit.
Expand All @@ -363,7 +363,7 @@ Note:
* For the second input, at least one of the field must be provided, else it returns back to main menu.

Example of usage:
1. `edit incomes 3`
1. `edit income 3`
2. `a/10000 d/15/10/2024`

Expected Usage of Feature:
Expand Down
Binary file modified docs/images/EditExpense_ExpectedOutput.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/EditIncomes_ExpectedOutput.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/main/java/seedu/budgetbuddy/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ public static void displayHelpMessage(){
"Example:\nlist remaining budget\n" +
"10. Edit expense fields (with Category, Amount or Date). Note: Provide at least one of the 3 fields" +
" in the second line of input. Refer to example below.\n" +
"Example:\nedit expenses 3\n" +
"Example:\nedit expense 3\n" +
"a/1000 d/12/10/2024 c/food\n" +
"11. Edit income fields (with Amount or Date). Note: Provide at least one of the 2 fields in the" +
"second line of input. Refer to example below.\n" +
"Example:\nedit incomes 3\n" +
"Example:\nedit income 3\n" +
"a/1000 d/12/10/2024\n" +
"12. Display income spent. Note - (optional)month - m/MM/YYYY\n" +
"Example:\ndisplay income spent m/10/2024\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public EditExpenseCommand(Expense expense) {
* @return True if the command matches "edit expenses", false otherwise.
*/
public static boolean isCommand(String command) {
return command.startsWith("edit expenses");
return command.startsWith("edit expense");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public EditIncomeCommand(Income income) {
* @return True if the command matches "edit incomes", false otherwise.
*/
public static boolean isCommand(String command) {
return command.startsWith("edit incomes");
return command.startsWith("edit income");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ public class EditExpenseValidator {
* @return command object
*/
public static Command processFirstCommand(String command) {
if (command.equals("edit expenses")) {
if (command.equals("edit expense")) {
return new IncorrectCommand("No index detected, try again with an index.");
}
if (command.startsWith("edit expenses")) {
return new IncorrectCommand("Invalid input");
}
try {
String trimmedCommand = command.substring("edit expenses ".length());
String trimmedCommand = command.substring("edit expense ".length());
String[] parts = trimmedCommand.split(" ");
int editIndex = Integer.parseInt(parts[0]);
if (editIndex < 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ public class EditIncomeValidator {
* @return command object
*/
public static Command processFirstCommand(String command) {
if (command.equals("edit incomes")) {
if (command.equals("edit income")) {
return new IncorrectCommand("No index detected, try again with an index.");
}
if (command.startsWith("edit incomes")) {
return new IncorrectCommand("Invalid input");
}
try {
String trimmedCommand = command.substring("edit incomes ".length());
String trimmedCommand = command.substring("edit income ".length());
String[] parts = trimmedCommand.split(" ");
int editIndex = Integer.parseInt(parts[0]);
if (editIndex < 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ void createTestCase (){
@Test
void processFirstCommand_validIndexGiven_expectEditExpenseCommandType() {
createTestCase();
String userInput = "edit expenses 1";
String userInput = "edit expense 1";
Command validCommand = EditExpenseValidator.processFirstCommand(userInput);
assertEquals(EditExpenseCommand.class, validCommand.getClass());
}

@Test
void processFirstCommand_invalidInputGiven_expectIncorrectCommandType() {
String userInput = "edit expenses 50";
String userInput = "edit expense 50";
Command invalidCommand = EditExpenseValidator.processFirstCommand(userInput);
assertEquals(IncorrectCommand.class ,invalidCommand.getClass());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ void createTestCase (){
@Test
void processFirstCommand_validIndexGiven_expectEditExpenseCommandType() {
createTestCase();
String userInput = "edit incomes 1";
String userInput = "edit income 1";
Command validCommand = EditIncomeValidator.processFirstCommand(userInput);
assertEquals(EditIncomeCommand.class, validCommand.getClass());
}

@Test
void processFirstCommand_invalidInputGiven_expectIncorrectCommandType() {
String userInput = "edit incomes 50";
String userInput = "edit income 50";
Command invalidCommand = EditIncomeValidator.processFirstCommand(userInput);
assertEquals(IncorrectCommand.class ,invalidCommand.getClass());
}
Expand Down
10 changes: 5 additions & 5 deletions text-ui-test/input.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ add income tutor a/1500 d/20/10/2023
add expense food a/550 d/30/10/2023
display income spent m/10/2023
list expenses
edit expenses 1
edit expense 1
a/50
add expense Fridge a/5000 d/1/2/2024 c/others
add budget a/2000 m/02/2024
list remaining budget
list incomes
edit incomes 1
edit income 1
a/10000 d/10/12/2024
edit incomes -10
edit incomes 50
edit incomes 3
edit income -10
edit income 50
edit income 3
c/food
list incomes
bye

0 comments on commit 1ce4965

Please sign in to comment.