static void Main() { DepositAccount myDeposit = new DepositAccount(Customer.Individual, 0, 1); myDeposit.Deposit(2500); Console.WriteLine("Balance: {0}", myDeposit.Balance); Console.WriteLine("Interest: {0}", myDeposit.CalculateInterest(12)); Console.WriteLine("... Withdrawing $2000 ..."); myDeposit.Withdraw(-2000); // myDeposit.Withdraw(-2800); - this will throw exeption Console.WriteLine("New Balance {0}", myDeposit.Balance); Console.WriteLine("new Interest: {0}", myDeposit.CalculateInterest(12)); }
static void Main() { DepositAccount depositPersonAcc = new DepositAccount(Customer.Individual, 10000.00M, 2.5); Console.WriteLine("Individual deposit account(balance = {0}) interest for 12 months = {1:F2}." , depositPersonAcc.Balance, depositPersonAcc.CalculateInterest(12)); Console.WriteLine("Withdrawing from this account 9500."); depositPersonAcc.Withdraw(9500); Console.WriteLine("Individual deposit account(balance = {0}) interest for 12 months = {1:F2}." , depositPersonAcc.Balance, depositPersonAcc.CalculateInterest(12)); Console.WriteLine("Try to withdraw 501."); depositPersonAcc.Withdraw(501); LoanAccount loanPersonAcc = new LoanAccount(Customer.Individual, -15250.35M, 2.0); LoanAccount loanCompanyAcc = new LoanAccount(Customer.Company, -50000, 1.5); Console.WriteLine("\nIndividual loan account(balance = {0}) interest for 3 months = {1:F2}." , loanPersonAcc.Balance, loanPersonAcc.CalculateInterest(3)); Console.WriteLine("Individual loan account(balance = {0}) interest for 10 months = {1:F2}." , loanPersonAcc.Balance, loanPersonAcc.CalculateInterest(10)); Console.WriteLine("Company loan account(balance = {0}) interest for 10 months = {1:F2}." , loanCompanyAcc.Balance, loanCompanyAcc.CalculateInterest(10)); Console.WriteLine("Company loan account(balance = {0}) interest for 2 months = {1:F2}." , loanCompanyAcc.Balance, loanCompanyAcc.CalculateInterest(2)); MortgageAccount mortgagePersonAcc = new MortgageAccount(Customer.Individual, -2500.50M, 3.2); MortgageAccount mortgageCompanyAcc = new MortgageAccount(Customer.Company, -1000M, 1); Console.WriteLine("\nIndividual mortgage account(balance = {0}) interest for 6 months = {1:F2}." , mortgagePersonAcc.Balance, mortgagePersonAcc.CalculateInterest(6)); Console.WriteLine("Individual mortgage account(balance = {0}) interest for 10 months = {1:F2}." , mortgagePersonAcc.Balance, mortgagePersonAcc.CalculateInterest(10)); Console.WriteLine("Individual mortgage account(balance = {0}) interest for 12 months = {1:F2}." , mortgageCompanyAcc.Balance, mortgageCompanyAcc.CalculateInterest(12)); //for first 12 months interest is 60$ Console.WriteLine("Individual mortgage account(balance = {0}) interest for 24 months = {1:F2}." , mortgageCompanyAcc.Balance, mortgageCompanyAcc.CalculateInterest(24)); //for 24 months interest is 60$ for first 12months + 120$ for next 12 months }
static void Main() { var bajPesho = Customer.Individual; var leliaMarche = Customer.Individual; var mrAnderson = Customer.Individual; var google = Customer.Company; var microsoft = Customer.Company; var facebook = Customer.Company; var bajPeshoAccount = new DepositAccount(bajPesho, 200, 7); var leliaMarcheAccount = new MortgageAccount(leliaMarche, 200, 7); var mrAndersonAccount = new LoanAccount(mrAnderson, 200, 7); var googleAccount = new DepositAccount(google, 200, 7); var microsoftAccount = new MortgageAccount(microsoft, 200, 7); var facebookAccount = new LoanAccount(facebook, 200, 7); googleAccount.Withdraw(100); // Console.WriteLine(googleAccount.Balance); facebookAccount.Deposit(100); // Console.WriteLine(facebookAccount.Balance); var accounts = new List <IAccount>() { googleAccount, microsoftAccount, facebookAccount, bajPeshoAccount, leliaMarcheAccount, mrAndersonAccount }; var sortedAccounts = accounts.OrderByDescending(account => account.Balance); foreach (var account in sortedAccounts) { decimal interestFirstMonths = account.CalculateInterest(3); decimal interest = account.CalculateInterest(13); Console.WriteLine("customer: {0} - balance: {1}; first months interest: {2}; interest: {3}" , account.Customer, account.Balance, interestFirstMonths, interest); } }
public static void Main() { var client = new Individual("Client", "Sofia", 23); var account = new DepositAccount(client, 1000, 2); Console.WriteLine(account.Balance); //making a deposit of 100 account.Deposit(100); //money after the deposit Console.WriteLine(account.Balance); //interest after 14months Console.WriteLine(account.CalculaterInterest(14)); //making a withdraw account.Withdraw(500); Console.WriteLine(account.Balance); var account1 = new LoanAccount(new Company("ComapanySoft", "Varna", "1024443"), 10400, 7); //interest after 6months Console.WriteLine(account1.CalculaterInterest(6)); }
static void Main(string[] args) { //新建一个个人存款账户 DepositAccount A = new DepositAccount("WHM", 0); //存款 A.Deposit(20000); //取款 A.Withdraw(5000); //获得利息 Console.WriteLine("您的利息为:{0}。", A.GetInterest(18, 0.035)); //新建一个企业贷款账户 LoanAccount B = new LoanAccount("WH", 1); //存款 B.Deposit(20000); //获得利息 Console.WriteLine("您的利息为:{0}。", B.GetInterest(27, 0.037)); //抵押贷款同理,此处不给出 }
public void TestWithdrawMethod() { Customer accountCustomer = new IndividualCustomer( "2343PJ34752", "William", "Harris", "1 Microsoft Way, Redmond, WA", "1-888-553-6562"); DepositAccount account = new DepositAccount( accountCustomer, 2500, 1.0825M, 12); account.Withdraw(400M); Assert.AreEqual(2100M, account.Balance); }