Skip to content

Commit

Permalink
Merge pull request nus-cs2113-AY2223S2#94 from tyuyang/branch-debugging
Browse files Browse the repository at this point in the history
Branch debugging
  • Loading branch information
manushridiv authored Mar 28, 2023
2 parents 160dd24 + 7dd49c6 commit 00cb959
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package seedu.bankwithus.exceptions;

public class NoTransactionsFoundException extends Exception {

}
8 changes: 7 additions & 1 deletion src/main/java/seedu/bankwithus/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import seedu.bankwithus.exceptions.InsufficientBalanceException;
import seedu.bankwithus.exceptions.NegativeAmountException;
import seedu.bankwithus.exceptions.NoAccountException;
import seedu.bankwithus.exceptions.NoTransactionsFoundException;
import seedu.bankwithus.exceptions.SaveFileIsEmptyException;

import java.io.IOException;
Expand Down Expand Up @@ -159,7 +160,12 @@ public void parseUserInput(String input) throws CommandNotFoundException, IOExce
accountList.deleteAccount(args);
break;
case "view-transactions-all":
transactionList.printAllTransactions();
try {
transactionList.printAllTransactions();
ui.printLine();
} catch (NoTransactionsFoundException e) {
ui.noTransactionsFoundError();
}
break;
default:
throw new CommandNotFoundException();
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/seedu/bankwithus/ui/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,9 @@ public void showExceedsWithdrawalLimitError() {
System.out.println("Apologies! Your transaction did not go through as it will result");
System.out.println("in you exceeding your withdrawal limit!");
}

public void noTransactionsFoundError() {
System.out.println("No transactions found!");
printLine();
}
}
6 changes: 5 additions & 1 deletion src/main/java/seedu/bankwithus/user/TransactionList.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package seedu.bankwithus.user;

import seedu.bankwithus.exceptions.CorruptedSaveFileException;
import seedu.bankwithus.exceptions.NoTransactionsFoundException;
import seedu.bankwithus.exceptions.SaveFileIsEmptyException;
import seedu.bankwithus.parser.Parser;
import seedu.bankwithus.ui.Ui;
Expand Down Expand Up @@ -55,7 +56,10 @@ public int getSize() {
return size;
}

public void printAllTransactions() {
public void printAllTransactions() throws NoTransactionsFoundException {
if (size == 0) {
throw new NoTransactionsFoundException();
}
for (int i = 0; i < size; i++) {
System.out.println(transactions.get(i).toString());
}
Expand Down
1 change: 1 addition & 0 deletions text-ui-test/EXPECTED.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,6 @@ Balance: $1100.21
----------------------------
Account Name: hihi Transaction Type: deposit Amount: 100.21 Date: 28/03/2023
Account Name: sherlock Transaction Type: withdraw Amount: 100 Date: 28/03/2023
----------------------------
Not a valid command!
Goodbye! Hope to see you again! :)

0 comments on commit 00cb959

Please sign in to comment.