Skip to content

Instantly share code, notes, and snippets.

@djiwandou
Created October 10, 2019 09:56
Show Gist options
  • Select an option

  • Save djiwandou/c6060951abf63aeed096110da1086adf to your computer and use it in GitHub Desktop.

Select an option

Save djiwandou/c6060951abf63aeed096110da1086adf to your computer and use it in GitHub Desktop.
public class BankAccount
{
public BankAccount(int accountAge, int creditScore, AccountInterest accountInterest)
{
AccountAge = accountAge;
CreditScore = creditScore;
AccountInterest = accountInterest;
}
public int AccountAge { get; private set; }
public int CreditScore { get; private set; }
public AccountInterest AccountInterest { get; private set; }
public double CalculateInterestRate()
{
if (CreditScore > 800)
return 0.02;
if (AccountAge > 10)
return 0.03;
return 0.05;
}
}
public class AccountInterest
{
public BankAccount Account { get; private set; }
public AccountInterest(BankAccount account)
{
Account = account;
}
public double InterestRate
{
get { return Account.CalculateInterestRate(); }
}
public bool IntroductoryRate
{
get { return Account.CalculateInterestRate() < 0.05; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment