Skip to content

Commit

Permalink
Merge pull request #134 from ChongXern/master
Browse files Browse the repository at this point in the history
Fix issues #126, #104 and #95
  • Loading branch information
ChongXern committed Apr 12, 2024
2 parents 7da853d + a58ba23 commit dbde541
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/main/java/command/ViewHistoryCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ public ViewHistoryCommand(String[] commandParts) {
super(false,commandParts);
}

public String execute(TransactionManager manager) throws Exception{
public String execute(TransactionManager manager) throws Exception {
//@@author Kishen271828
//String numTransactionsString = null;
int numTransactions = 0;
if (commandParts[1].startsWith("n/")) {
String numTransactionsString = commandParts[1].substring(2);
numTransactions = Integer.parseInt(numTransactionsString);
try {
numTransactions = Integer.parseInt(numTransactionsString);
if (numTransactions <= 0) {
throw new IllegalArgumentException("Sorry, please input a positive index.");
}
} catch (NumberFormatException e) {
throw new IncorrectCommandSyntaxException(commandParts[0]);
}
} else if (commandParts[1].equals("all")) {
numTransactions = manager.getTransactionListSize();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public Inflow editInflow(int index, Transaction<?> updatedTransaction) throws Ex

inflows.editTransactionIndex(numOfInflows - index, (Inflow) updatedTransaction);
inflows.sortTransactions();
return (Inflow) transactionEdited;
return transactionEdited;
}

public Outflow editOutflow(int index, Transaction<?> updatedTransaction) throws Exception {
Expand Down

0 comments on commit dbde541

Please sign in to comment.