public static void exampleList(List <CurrentAccount> list) { Address address1 = new Address("FirstStreet", 1, "FirstCity", 12345); Client client1 = new Client("Ed", "Small", 12345678910, address1); CurrentAccount account1 = new CurrentAccount(1000, client1, 1); Address address2 = new Address("SecondStreet", 1, "SecondCity", 23456); Client client2 = new Client("Jim", "Big", 54345678910, address2); CurrentAccount account2 = new CurrentAccount(500, client2, 2); list.Add(account1); list.Add(account2); }
public static void addCurrentAccount(List <CurrentAccount> CurrentAccountsList, ref int idNumber) { CurrentAccount nextAccount = new CurrentAccount(); nextAccount.setAccountDetails(ref idNumber); foreach (CurrentAccount account in CurrentAccountsList) { if (account.AccountOwner.Pesel == nextAccount.AccountOwner.Pesel) { Console.WriteLine("Error. Client with " + nextAccount.AccountOwner.Pesel + " PESEL has already had Current Accout."); break; } else { CurrentAccountsList.Add(nextAccount); Console.WriteLine("Account has been created."); break; } } }