@@ -47,18 +47,15 @@ public BankAccountNumber(string value)
4747
4848public record AccountHolderDetails ( string Name , string CustomerId , string Address ) ;
4949
50- // TODO: Task 6: Step 3 - Add the DailyTotal record near the record/type definitions.
51- public record DailyTotal ( DateOnly Day , decimal Total , int Count ) ;
52-
53- // TODO: Task 4: Step 1 - Add the ILedgerEntry interface near the record/type definitions.
50+ // Task 4: Step 1 - Add the ILedgerEntry interface near the record/type definitions.
5451public interface ILedgerEntry
5552{
5653 decimal Amount { get ; }
5754 DateTime Date { get ; }
5855 string Description { get ; }
5956}
6057
61- // TODO: Task 4: Step 2 - Update Transaction to implement ILedgerEntry.
58+ // Task 4: Step 2 - Update Transaction to implement ILedgerEntry.
6259public record Transaction ( decimal Amount , DateTime Date , string Description ) : ILedgerEntry
6360{
6461 public override string ToString ( )
@@ -67,24 +64,8 @@ public override string ToString()
6764 }
6865}
6966
70- // TODO: Task 4: Step 3 - Add the generic Ledger<TEntry> class (where TEntry : ILedgerEntry).
71- public sealed class Ledger < TEntry > where TEntry : ILedgerEntry
72- {
73- private readonly List < TEntry > _entries = new ( ) ;
74-
75- public IReadOnlyList < TEntry > Entries => _entries ;
76-
77- public void Add ( TEntry entry )
78- {
79- if ( entry is null ) throw new ArgumentNullException ( nameof ( entry ) ) ;
80- _entries . Add ( entry ) ;
81- }
82-
83- public decimal Total ( ) => _entries . Sum ( e => e . Amount ) ;
84- }
85-
86- // TODO: Task 4: Step 8 - Add a second ledger entry type (e.g., Fee) that implements ILedgerEntry.
87- public record Fee ( decimal Amount , DateTime Date , string Description ) : ILedgerEntry ;
67+ // Task 6: Step 1 - Add the DailyTotal record near the record/type definitions.
68+ public record DailyTotal ( DateOnly Day , decimal Total , int Count ) ;
8869
8970public class BankAccount
9071{
@@ -93,13 +74,11 @@ public class BankAccount
9374 public decimal Balance { get ; private set ; }
9475 public AccountHolderDetails AccountHolder { get ; }
9576
96- // TODO: Task 2: Step 1 - Replace the transactions collection with a private backing field.
97- // TODO: Task 2: Step 3 - Expose transactions as a read-only generic view (IReadOnlyList<Transaction>).
98- // TODO: Task 4: Step 5 - Refactor BankAccount to store transactions in Ledger<Transaction>.
77+ // Task 4: Step 4 - Refactor BankAccount to store transactions in Ledger<Transaction>.
9978 private readonly Ledger < Transaction > _ledger = new ( ) ;
100-
10179 public IReadOnlyList < Transaction > Transactions => _ledger . Entries ;
10280
81+
10382 public BankAccount ( BankAccountNumber accountNumber , BankAccountType accountType , AccountHolderDetails accountHolder , decimal initialBalance = 0 )
10483 {
10584 AccountNumber = accountNumber ;
@@ -110,9 +89,8 @@ public BankAccount(BankAccountNumber accountNumber, BankAccountType accountType,
11089
11190 public void AddTransaction ( decimal amount , string description )
11291 {
113- // TODO: Task 2: Step 4 - Update AddTransaction to add to the backing field.
114- // TODO: Task 4: Step 6 - Update AddTransaction to call _ledger.Add(...) once Ledger<Transaction> is introduced.
11592
93+ // Task 4: Step 5 - Update AddTransaction to call _ledger.Add(...) once Ledger<Transaction> is introduced.
11694 Balance += amount ;
11795 _ledger . Add ( new Transaction ( amount , DateTime . Now , description ) ) ;
11896 }
@@ -124,20 +102,21 @@ public string DisplayAccountInfo()
124102
125103 public void DisplayTransactions ( )
126104 {
127- // TODO: Task 2: Step 5 - Update DisplayTransactions to iterate the public read-only Transactions view.
128- // TODO: Task 4: Step 7 - Ensure display iterates _ledger.Entries (or the Transactions view backed by it).
129-
130105 Console . WriteLine ( "Transactions:" ) ;
106+
107+ // Task 4: Step 6 - Ensure display iterates _ledger.Entries (or the Transactions view backed by it).
108+ // Task 2: Step 4 - Update DisplayTransactions to iterate the public read-only Transactions view.
131109 foreach ( var transaction in Transactions )
132110 {
133111 Console . WriteLine ( transaction ) ;
134112 }
135113 }
136114
137- // TODO: Task 2: Step 6 - (Optional) Add GetTransactions() returning IEnumerable<Transaction>.
115+ // Task 2: Step 5 - Add GetTransactions() returning IEnumerable<Transaction>.
138116 public IEnumerable < Transaction > GetTransactions ( ) => Transactions ;
139117
140- // TODO: Task 6: Step 4 - Add GetDailyTotals() returning IEnumerable<DailyTotal>.
118+
119+ // Task 6: Step 2 - Add GetDailyTotals() returning IEnumerable<DailyTotal>.
141120 public IEnumerable < DailyTotal > GetDailyTotals ( )
142121 {
143122 return Transactions
@@ -148,8 +127,7 @@ public IEnumerable<DailyTotal> GetDailyTotals()
148127
149128}
150129
151- // TODO: Task 3: Step 1 - Add the Bank class that stores accounts in Dictionary<BankAccountNumber, BankAccount>.
152-
130+ // Task 3: Step 1 - Add the Bank class that stores accounts in Dictionary<BankAccountNumber, BankAccount>.
153131public sealed class Bank
154132{
155133 private readonly Dictionary < BankAccountNumber , BankAccount > _accounts = new ( ) ;
@@ -175,7 +153,21 @@ public bool CloseAccount(BankAccountNumber number)
175153 => _accounts . Remove ( number ) ;
176154}
177155
178- // TODO: Task 4: Step 3 - Add the generic Ledger<TEntry> class (where TEntry : ILedgerEntry).
156+ // Task 4: Step 3 - Add the generic Ledger<TEntry> class (where TEntry : ILedgerEntry).
157+ public sealed class Ledger < TEntry > where TEntry : ILedgerEntry
158+ {
159+ private readonly List < TEntry > _entries = new ( ) ;
179160
180- // TODO: Task 4: Step 8 - Add a second ledger entry type (e.g., Fee) that implements ILedgerEntry.
161+ public IReadOnlyList < TEntry > Entries => _entries ;
181162
163+ public void Add ( TEntry entry )
164+ {
165+ if ( entry is null ) throw new ArgumentNullException ( nameof ( entry ) ) ;
166+ _entries . Add ( entry ) ;
167+ }
168+
169+ public decimal Total ( ) => _entries . Sum ( e => e . Amount ) ;
170+ }
171+
172+ // Task 4: Step 7 - Add a second ledger entry type (e.g., Fee) that implements ILedgerEntry.
173+ public record Fee ( decimal Amount , DateTime Date , string Description ) : ILedgerEntry ;
0 commit comments