From 5ba6e96b4eb1ec14c444bab4ca7b7d54036bd5d8 Mon Sep 17 00:00:00 2001 From: ChungZhiXuan Date: Tue, 17 Oct 2023 22:49:18 +0800 Subject: [PATCH 1/2] Display transaction index for each transaction --- src/main/java/seedu/nuscents/ui/Ui.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/seedu/nuscents/ui/Ui.java b/src/main/java/seedu/nuscents/ui/Ui.java index 8840449cc1..ab58839cd9 100644 --- a/src/main/java/seedu/nuscents/ui/Ui.java +++ b/src/main/java/seedu/nuscents/ui/Ui.java @@ -76,14 +76,19 @@ 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 %-8s %-20s %-5s %n", "S/N", "TYPE", "AMOUNT", "DATE", "DESCRIPTION"); + System.out.println(LINE); ArrayList transactions = transactionList.getTransactions(); for (Transaction transaction : transactions) { + int index = transactions.indexOf(transaction) + 1; if (transaction instanceof Allowance) { - System.out.println("|A| " + transaction.toString()); + System.out.printf("%-5s %-10s %-8s %-20s %-5s %n", index, "Allowance", + "$" + transaction.getAmount(), transaction.getFormattedDate(), transaction.getDescription()); } else if (transaction instanceof Expense) { - System.out.println("|E| " + transaction.toString()); + System.out.printf("%-5s %-10s %-8s %-20s %-5s %n", index, "Expense", + "$" + transaction.getAmount(), transaction.getFormattedDate(), transaction.getDescription()); } - } System.out.println(LINE); } From 5b065e3c7145dcb5a4e6a77526c9c3584f63eae2 Mon Sep 17 00:00:00 2001 From: ChungZhiXuan Date: Tue, 17 Oct 2023 23:02:04 +0800 Subject: [PATCH 2/2] Display additional info for transactions --- src/main/java/seedu/nuscents/ui/Ui.java | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/java/seedu/nuscents/ui/Ui.java b/src/main/java/seedu/nuscents/ui/Ui.java index ab58839cd9..34351c29cd 100644 --- a/src/main/java/seedu/nuscents/ui/Ui.java +++ b/src/main/java/seedu/nuscents/ui/Ui.java @@ -77,17 +77,27 @@ public static void showTransactionList(TransactionList transactionList) { } System.out.println("Here are the transactions in your list:"); System.out.println(LINE); - System.out.printf("%-5s %-10s %-8s %-20s %-5s %n", "S/N", "TYPE", "AMOUNT", "DATE", "DESCRIPTION"); + System.out.printf("%-5s %-10s %-7s %-18s %-15s %-5s %n", + "S/N", "TYPE", "AMOUNT", "DATE", "DESCRIPTION", "NOTE"); System.out.println(LINE); ArrayList 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.printf("%-5s %-10s %-8s %-20s %-5s %n", index, "Allowance", - "$" + transaction.getAmount(), transaction.getFormattedDate(), transaction.getDescription()); + 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.printf("%-5s %-10s %-8s %-20s %-5s %n", index, "Expense", - "$" + transaction.getAmount(), transaction.getFormattedDate(), transaction.getDescription()); + System.out.printf("%-5s %-10s %-7s %-18s %-15s %-5s %n", index, "Expense", + "$" + transaction.getAmount(), transaction.getFormattedDate(), transaction.getDescription(), + note); } } System.out.println(LINE);