Created
October 10, 2019 09:56
-
-
Save djiwandou/c6060951abf63aeed096110da1086adf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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