Skip to content
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

Display serial number and additional info for list feature #26

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/main/java/seedu/nuscents/ui/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,29 @@ public static void showTransactionList(TransactionList transactionList) {
return;
}
System.out.println("Here are the transactions in your list:");
System.out.println(LINE);
System.out.printf("%-5s %-10s %-7s %-18s %-15s %-5s %n",
"S/N", "TYPE", "AMOUNT", "DATE", "DESCRIPTION", "NOTE");
System.out.println(LINE);
ArrayList<Transaction> transactions = transactionList.getTransactions();
for (Transaction transaction : transactions) {
int index = transactions.indexOf(transaction) + 1;
String additionalInfo = transaction.getAdditionalInfo();
String note;
if (additionalInfo.isEmpty()) {
note = "-";
} else {
note = additionalInfo;
}
if (transaction instanceof Allowance) {
System.out.println("|A| " + transaction.toString());
System.out.printf("%-5s %-10s %-7s %-18s %-15s %-5s %n", index, "Allowance",
"$" + transaction.getAmount(), transaction.getFormattedDate(), transaction.getDescription(),
note);
} else if (transaction instanceof Expense) {
System.out.println("|E| " + transaction.toString());
System.out.printf("%-5s %-10s %-7s %-18s %-15s %-5s %n", index, "Expense",
"$" + transaction.getAmount(), transaction.getFormattedDate(), transaction.getDescription(),
note);
}

}
System.out.println(LINE);
}
Expand Down
Loading