//Constructor public Account(Customer customer, DateTime startDate, decimal balance, decimal interestRate) { this.Customer = customer; this.StartDate = startDate; this.Balance = balance; this.MonthlyInterestRate = interestRate; }
//constructor protected Account(Customer customer, DateTime creationDate, decimal balance = 0, decimal interest = 0) { this.Cutomer = customer; this.Balance = balance; this.Interest = interest; this.CreationDate = creationDate; }
private void ValidateLastName(Customer iCustomer) { if (!Regex.IsMatch(iCustomer.LastName, "[A-Z,a-z]")) { throw new ArgumentException("Please enter only characters"); } }
private void ValidateAge(Customer iCustomer) { if (iCustomer.Age <= 18) { throw new ArgumentException("Customer should be older than 18 years"); } }
public override decimal CalculateInterest(Customer client) { decimal numOfMonts=this.PeriodInMonts; if (client == Customer.Individual) { numOfMonts -= 6; } else { if (numOfMonts>12) { //more than 12 monts mortgage decimal currentNumOfMonts = 0; for (int i = 1; i <= numOfMonts; i++) { if (i<=12) { currentNumOfMonts += 0.5m; } currentNumOfMonts++; } numOfMonts = currentNumOfMonts; } else { //only 1 year mortgage numOfMonts /= 2; } } decimal interest= numOfMonts * this.InterestRate; return interest; }
private void ValidatePhoneNumber(Customer iCustomer) { if (iCustomer.PhoneNumber.ToString().Length != 10) { throw new ArgumentException("Please enter valid phone number"); } }
private Customer KindOfCustomer; //this is object from class Customer #endregion Fields #region Constructors //constructor public Account() { this.KindOfCustomer = kindOfCustomer; this.Balance = balance; this.InterestRate = interestRate; this.NumberOfMounths = numberOfMounts; }
//Constructor public Account(string customerID, Customer client, decimal balance, decimal interestRate, int periodInMonts) { this.CustomerID = customerID; this.client = client; this.balance = balance; this.interestRate = interestRate; this.periodInMonts = periodInMonts; }
public DepositAccount( Customer owner, decimal balance, decimal monthlyInterestRate, int periodInMonths) : base(owner, balance, monthlyInterestRate) { this.interestCalculator = new DepositAccountInterestCalculator( balance, monthlyInterestRate, periodInMonths); }
public int AddCustomer(Customer iCustomer) { ValidateLastName(iCustomer); ValidateFirstName(iCustomer); ValidatePhoneNumber(iCustomer); ValidateAge(iCustomer); Account account = new Account(); iCustomer.BankAccount = account; customers.Add(iCustomer); return iCustomer.BankAccount.AccountNumber; }
public override decimal CalculateInterest(Customer client) { int numOfMonts = this.PeriodInMonts; if (client == Customer.Individual) { numOfMonts -= 3; } else { numOfMonts -= 2; } decimal interest = numOfMonts * this.InterestRate; return interest; }
public LoanAccountInterestCalculator( Customer owner, decimal principal, decimal monthlyInterestRate, int periodInMonths) { this.Principal = principal; if (owner is IndividualCustomer) { this.InterestFreePeriodInMonths = 3; } else { this.InterestFreePeriodInMonths = 2; } this.MonthlyInterestRate = monthlyInterestRate; this.PeriodInMonths = periodInMonths; }
public override decimal CalculateInterest(Customer client) { decimal balance = this.Balance; if (balance>0 && balance<1000) { return 0; } else { int numOfMonts = this.PeriodInMonts; decimal interest = numOfMonts * this.InterestRate; return interest; } }
public Account(Customer customer, decimal startBalance, double interestRate, byte months, DateTime dateOfCreation) { if (startBalance <= 0) { throw new ArgumentOutOfRangeException("The start balance must be bigger than 0."); } else { this.balance = startBalance; } this.customer = customer; this.interestRate = interestRate / 100; this.months = months; this.dateOfCreation = dateOfCreation; }
public MortgageAccount(Customer customer, decimal balance, decimal interestRate) : base(customer, balance, interestRate) { }
public Loan(decimal balance, float interestRate, Customer customer) : base(balance, interestRate, customer) { }
//constructor public Mortgage(Customer kindOfCustomer, decimal balance, decimal interestRate, int mortgagePeriod) : base(kindOfCustomer, balance, interestRate) { this.MortgagePeriod = mortgagePeriod; }
public Mortgage(decimal balance, float interestRate, Customer customer) : base(balance, interestRate, customer) { }
protected Account(Customer customer, decimal balance, decimal interest) { this.customer = customer; this.balance = balance; this.interest = interest; }
/// <summary> /// Make a deposit to a new customer. Enter customer name, starting balance and interest rate. /// </summary> /// <param name="customer"></param> /// <param name="startBalance"></param> /// <param name="interestRate"></param> public Deposit(Customer customer, decimal startBalance, double interestRate, byte months) : base(customer, startBalance, interestRate, months, DateTime.Now) { }
/// <summary> /// Get new customer a loan. Enter customer name, loan sum and interest rate. /// </summary> /// <param name="customer"></param> /// <param name="startBalance"></param> /// <param name="interestRate"></param> public Loan(Customer customer, decimal loanSum, double interestRate, byte months) : base(customer, loanSum, interestRate, months, DateTime.Now) { }
//base constructor public Account(decimal balance, float interestRate, Customer customer) { this.balance = balance; this.interestRate = interestRate; this.customer = customer; }
public Loan(Customer owner, decimal balance, decimal interestRate) : base(owner, balance, interestRate) { }
public BankAccount(Customer owner, decimal balance, decimal interestRate) { this.Owner = owner; this.Balance = balance; this.InterestRate = interestRate; }
protected Account(Customer customer, decimal balance, decimal interestRate) { this.Customer = customer; this.Balance = balance; this.InterestRate = interestRate; }
//constructor public AccountLoan(Customer customer, decimal balance, double interest) { this.Customer = customer; this.Balance = balance; this.InterestRate = interest; }
public DepositAccount(Customer customer, decimal balance, decimal interestRate) : base(customer, balance, interestRate) { }
public BankAccountBase(Customer customer, decimal balance, decimal interestRate) { this.Customer = customer; this.Balance = balance; this.InterestRate = interestRate; }
public LoanAccount(Customer client, decimal balance, decimal interest) : base(client, balance, interest) { }
public MortgageAccount(Customer customer, DateTime creationDate, decimal balance = 0, decimal interest = 0) : base(customer, creationDate, balance, interest) { }