static void Main() { Bank accounts = new Bank(); accounts.AddAccount(new Deposit(CustomerType.Individual, 300, 0.07M)); accounts.AddAccount(new Deposit(CustomerType.Company, 10000, 0.08M)); accounts.AddAccount(new Loan(CustomerType.Individual, 2000, 0.03M)); accounts.AddAccount(new Loan(CustomerType.Company, 12000, 0.04M)); accounts.AddAccount(new Mortgage(CustomerType.Individual, 15000, 0.02M)); accounts.AddAccount(new Mortgage(CustomerType.Company, 30000, 0.05M)); foreach (var account in accounts.Accounts) { Console.WriteLine(account); Console.WriteLine(); } Console.WriteLine("Calculated interest for each type account"); foreach (var account in accounts.Accounts) { Console.WriteLine("{0}: {1}",account.GetType().Name, account.CalculateInterest(10)); } Console.WriteLine(); Deposit myDeposit = new Deposit(CustomerType.Individual, 1500, 0.05M); Console.WriteLine("My account transaction:"); myDeposit.Deposit(500); myDeposit.Withdraw(700); Console.WriteLine(myDeposit); }
public static void Main() { Bank bank = new Bank(); bank.AddAccount(new DepositAccount(CustomerType.Company, 10m, 5.2m)); bank.AddAccount(new LoanAccount(CustomerType.Individual, 7m, 2.3m)); bank.AddAccount(new MortgageAccount(CustomerType.Company, 2.3m, 5.4m)); Console.WriteLine(bank); }
private static Bank LoadAccounts() { Bank bank = new Bank("Bank DSK"); bank.AddAccount(new MortgageAccount(new IndividualCustomer ("Pesho Peshev"), 50000.0m, 25)); bank.AddAccount(new DepositAccount(new CompanyCustomer ("Sparco"), 7500.0m, 12)); bank.AddAccount(new LoanAccount(new CompanyCustomer ("'Northen Star"), 175000.0m, 22)); bank.AddAccount(new MortgageAccount(new IndividualCustomer ("Ivan Ivanov"), 30500.0m, 50)); bank.AddAccount(new DepositAccount(new CompanyCustomer ("McCompany"), 12450.0m, 13)); bank.AddAccount(new LoanAccount(new IndividualCustomer ("Desi Veleva"), 129.0m, 2)); return bank; }
static void Main() { var bank = new Bank(); var rand = new Random(); bank.AddAccount(new MortgageAccount(new Individual("Slim Shady"), 12000.0M, 3.3M)); bank.AddAccount(new DepositAccount(new Company("Telerik Academy"), 75000.0M, 1.2M)); bank.AddAccount(new LoanAccount(new Company("Telenor"), 100000.0M, 2.2M)); bank.AddAccount(new LoanAccount(new Individual("Doctor Dre"), 12900.0M, 2.4M)); foreach (var account in bank.GetAccounts()) { var months = rand.Next(5, 13); Console.WriteLine("{0}'s interest amount after {1} months: {2:F2}", account.Client.Name, months, account.CalculateInterest(months)); } }
static void Main() { var customer = new DepositAccount(Customer.Individual, 3000, 6.7); var anotherCustomer = new MortgageAccount(Customer.Company, 15.5M, 9.9); Console.WriteLine(customer.CalculateInterestRate(12)); Console.WriteLine(customer.Balance); customer.Deposit(505.5M); Console.WriteLine(customer.Balance); var accounts = new Bank("UBB"); accounts.AddAccount(customer); accounts.AddAccount(anotherCustomer); Console.WriteLine(accounts.ToString()); }
static void Main() { Bank DSK = new Bank() { Accounts = new List<Account> { new LoanAcc(CustomerTypes.Company, 10000.20, 0.07,"Telerik"), new DepositAcc(CustomerTypes.Individual, 999, 0.1, "Pesho"), new MortgageAcc(CustomerTypes.Individual, 100, 0.2, "Ivan") } }; Console.WriteLine("Company loan account:"); Console.WriteLine(DSK[0].CalcInterest(10)); Console.WriteLine("Individual deposit account with under 1000 leva:"); Console.WriteLine(DSK[1].CalcInterest(20)); Console.WriteLine("Individual mortgage account:"); Console.WriteLine(DSK[2].CalcInterest(4)); }
static void Main() { Bank bank = new Bank("SomeBank"); Customer newOwner = new Customer("Stamat", CustomerType.Individual); Deposit deposit = new Deposit(newOwner, 1000, 5.5m); bank.AddAccount(deposit); Customer secondOwner = new Customer("SomeLargeCompanyWitchConstructsTermometri", CustomerType.Company); Mortgage loan = new Mortgage(secondOwner, 10000000, 6.5m); bank.AddAccount(loan); Console.WriteLine(bank); for (int i = 0; i < bank.AllAccounts.Count; i++) { Console.WriteLine(); Console.WriteLine("Account {0}: ", i + 1); Console.WriteLine(bank.AllAccounts[i]); } }
public static void Main() { // Some accounts Deposite firstDeposite = new Deposite(Customers.Companies, 100000, 1.4m); Deposite secondDeposite = new Deposite(Customers.Individuals, 2500, 3.4m); Loan firstLoan = new Loan(Customers.Companies, 2400000m, 2.7m); Loan secondLoan = new Loan(Customers.Individuals, 7500, 1.001m); Mortgage firstMortgage = new Mortgage(Customers.Companies, 12400m, 5.1m); Mortgage secondMortgage = new Mortgage(Customers.Individuals, 4500, 0.11m); // Add and with draw some money firstDeposite.WithDrawMoney(1000.0m); secondDeposite.DepositeMoney(1000.0m); secondLoan.DepositeMoney(100); firstMortgage.DepositeMoney(600); // Calculate interests of amount decimal firstAmount = firstDeposite.CalculateInterestAmount(12); Console.WriteLine("Interest amount {0:F3} %", firstAmount); decimal secondAmount = firstMortgage.CalculateInterestAmount(7); Console.WriteLine("Interest amount {0:F3} %\n", secondAmount); // Create a bank Bank bank = new Bank(); // Adding some accounts in the bank bank.AddDepositeAccount(firstDeposite, secondDeposite); bank.AddLoanAccount(firstLoan, secondLoan); bank.AddMortgageAccount(firstMortgage, secondMortgage); // Print information about all account in the bank Console.WriteLine(bank.DepositeAccounts); Console.WriteLine(bank.LoanAccounts); Console.WriteLine(bank.MortgageAccounts); }
public static void Test() { Console.WriteLine("Test Bank Accounts"); Bank bank = new Bank( new List<Account> { new DepositAccount(new Customer("Gosho", CustomerType.Company)), new DepositAccount(new Customer("Pesho", CustomerType.Individual)), new LoanAccount(new Customer("Penka", CustomerType.Individual)), new LoanAccount(new Customer("Koliy", CustomerType.Company)), new MortgageAccount(new Customer("Lili", CustomerType.Individual)) } ); int month = 1; foreach (Account account in bank.Accounts) { account.CalcInterestRate(month); month++; } Console.WriteLine("....................................."); }
static void Main() { Bank myBank = new Bank("Birnici", "FBS004269"); myBank.Accounts.Add(new DepositAccounts(new IndividualsCustomers("Ivan Ivanov", "Glavnata str", "893873", 7804659087), 5000m, 30m, 12345678)); myBank.Accounts.Add(new MortgageAccounts(new CompaniesCustomers("TheBest OOD", "TheOnlyOne str", "+3592889765", 8653527848726), 100m, 40m, 58745698)); myBank.Accounts.Add(new LoanAccounts(new IndividualsCustomers("Krasimir Krasimirov", "MiddleOfNowhere", "+122734471", 8809136173), 9999m, 100m, 5689474)); myBank.Accounts.Add(new MortgageAccounts(new IndividualsCustomers("Elenko Elenkov", "File Elena", "+359889882345", 8903130490), 1020.345m, 4.5m, 46851245)); Console.WriteLine(); Console.WriteLine("<<<<<<<<<<<<<<<<<<< {0} >>>>>>>>>>>>>>>>>>>>", myBank); Console.WriteLine(); Console.WriteLine("<<<<<<<<<<< Accounts >>>>>>>>>>>>"); foreach (var account in myBank.Accounts) { Console.WriteLine(account); } Console.WriteLine(); Console.WriteLine("---------------------------------------------------------------------"); Console.WriteLine("\nDisplaying the result from the interest calculations:"); Console.WriteLine("---------------------------------------------------------------------"); try { int month = 7; foreach (var account in myBank.Accounts) { Console.WriteLine("Name: {1} \n Account type: {3} Period(months): {2} - Interest calc result: {0:c}", account.InterestCalculations(month), account.Customer.Name, month, account.GetType().Name); Console.WriteLine(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
static void Main() { // Making instances of all types of accounts with the two types of customers DepositAccount first = new DepositAccount(new IndividualCustomer("Jimmy Hendrix"), 1500, 5); DepositAccount second = new DepositAccount(new CompanyCustomer("Jimmy Hendrix"), 500, 5); LoanAccount third = new LoanAccount(new IndividualCustomer("Jimmy Hendrix"), 4000, 7); LoanAccount fourth = new LoanAccount(new CompanyCustomer("Jimmy Hendrix"), 50000, 3); MortgageAccount fifth = new MortgageAccount(new IndividualCustomer("Jimmy Hendrix"), 34000, 4); MortgageAccount sixth = new MortgageAccount(new CompanyCustomer("Jimmy Hendrix"), 19000, 9); // Testing the DepositMoney, WithDrawMoney and CalculateInterest methods for all account types Console.WriteLine("INDIVIDUAL DEPOSIT ACCOUNT:"); Console.WriteLine("Balance: {0}", first.Balance); first.DepositMoney(10); Console.WriteLine("Balance after deposit: {0}", first.Balance); first.WithDrawMoney(150); Console.WriteLine("Balance after withdraw: {0}", first.Balance); Console.WriteLine("Calculate interest: {0}", first.CalculateInterest(5)); Console.WriteLine(); Console.WriteLine("CUSTOMER DEPOSIT ACCOUNT: "); Console.WriteLine("Balance: {0}", second.Balance); second.DepositMoney(2000); Console.WriteLine("Balance after deposit: {0}", second.Balance); second.WithDrawMoney(1800); Console.WriteLine("Balance after withdraw: {0}", second.Balance); Console.WriteLine("Calculate interest: {0}", second.CalculateInterest(9)); Console.WriteLine(); Console.WriteLine("INDIVIDUAL LOAN ACCOUNT:"); Console.WriteLine("Balance: {0}", third.Balance); third.DepositMoney(60); Console.WriteLine("Balance after deposit: {0}", third.Balance); Console.WriteLine("Calculate interest: {0}", third.CalculateInterest(7)); Console.WriteLine(); Console.WriteLine("CUSTOMER LOAN ACCOUNT:"); Console.WriteLine("Balance: {0}", fourth.Balance); fourth.DepositMoney(60); Console.WriteLine("Balance after deposit: {0}", fourth.Balance); Console.WriteLine("Calculate interest: {0}", fourth.CalculateInterest(9)); Console.WriteLine(); Console.WriteLine("INDIVIDUAL MORTGAGE ACCOUNT:"); Console.WriteLine("Balance: {0}", fifth.Balance); fifth.DepositMoney(100); Console.WriteLine("Balance after deposit: {0}", fifth.Balance); Console.WriteLine("Calculate interest: {0}", fifth.CalculateInterest(6)); Console.WriteLine(); Console.WriteLine("CUSTOMER MORTGAGE ACCOUNT:"); Console.WriteLine("Balance: {0}", sixth.Balance); sixth.DepositMoney(100); Console.WriteLine("Balance after deposit: {0}", sixth.Balance); Console.WriteLine("Calculate interest: {0}", sixth.CalculateInterest(11)); // Testing the Bank class and the AddAccount method Bank newBank = new Bank(LoadList()); Console.WriteLine(); newBank.AddAccount(new DepositAccount(new IndividualCustomer("Joe Rogan"), 780, 3)); Console.WriteLine("Type of customer: " + newBank.Accounts[6].Customer.GetType().Name); Console.WriteLine("Name: " + newBank.Accounts[6].Customer.Name); Console.WriteLine("Balance: " + newBank.Accounts[6].Balance); Console.WriteLine("Interest rate: " + newBank.Accounts[6].InterestRate); }