Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace MyBank
- {
- class Customer
- {
- private string customerName;
- private long pNo;
- private const int ACCOUNT_LIMIT = 5;
- private List<BankAccount> accounts;
- // Constructor
- public Customer(string customerName, long pNo)
- {
- this.customerName = customerName;
- this.pNo = pNo;
- accounts = new List<BankAccount>();
- }
- // Getter/Setter
- public long PNo { get => pNo;}
- public string CustomerName { get => customerName; set => customerName = value; }
- // Creates a SavingsAccount
- public bool CreateSavingsAccount()
- {
- if (accounts.Count < ACCOUNT_LIMIT)
- {
- accounts.Add(new SavingsAccount(customerName));
- return true;
- }
- return false;
- }
- // Creates CreditAccount
- public bool CreateCreditAccount()
- {
- if (accounts.Count < ACCOUNT_LIMIT)
- {
- accounts.Add(new CreditAccount(customerName));
- return true;
- }
- return false;
- }
- // Deletes an account with accountNumber
- public bool DeleteAccount(int accountNumber)
- {
- foreach (BankAccount account in accounts)
- {
- if (accountNumber == account.AccountNumber)
- {
- accounts.Remove(account);
- return true;
- }
- }
- return false;
- }
- // Displays account information
- public string DisplayAccountInfo(int accountNumber)
- {
- foreach (BankAccount account in accounts)
- {
- if (accountNumber == account.AccountNumber)
- return account.DisplayAccount();
- }
- return "";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement