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