static void Main()
        {
            LoanAccount loanAcc1 = new LoanAccount(new IndividualCustomer(), 1000, 7.7);
            LoanAccount loanAcc2 = new LoanAccount(new CompanyCustomer(), 70000, 10.4);
            LoanAccount loanAcc3 = new LoanAccount(new IndividualCustomer(), 5000, 4.2);

            MortgageAccount mortgageAcc1 = new MortgageAccount(new CompanyCustomer(), 75500, 14.1);
            MortgageAccount mortgageAcc2 = new MortgageAccount(new IndividualCustomer(), 3200, 4.7);
            MortgageAccount mortgageAcc3 = new MortgageAccount(new CompanyCustomer(), 19500, 9.2);

            DepositAccount depositAcc1 = new DepositAccount(new CompanyCustomer(), 12000, 6.4);
            DepositAccount depositAcc2 = new DepositAccount(new IndividualCustomer(), 500, 1.2);
            DepositAccount depositAcc3 = new DepositAccount(new IndividualCustomer(), 2300, 3.9);

            Console.WriteLine(loanAcc1.CalculateInterestForAPeriod(2));
            Console.WriteLine(loanAcc2.CalculateInterestForAPeriod(5));
            Console.WriteLine(loanAcc3.CalculateInterestForAPeriod(3));

            Console.WriteLine(loanAcc1.CalculateInterestForAPeriod(4));
            Console.WriteLine(loanAcc2.CalculateInterestForAPeriod(8));
            Console.WriteLine(loanAcc3.CalculateInterestForAPeriod(1));

            //Console.WriteLine(loanAcc1.CalculateInterestForAPeriod(-1));  // this will throw an exception
            Console.WriteLine(loanAcc2.CalculateInterestForAPeriod(7));
            Console.WriteLine(loanAcc3.CalculateInterestForAPeriod(14));
        }
Example #2
0
        static void Main(string[] args)
        {
            var customerIndividual = new Individual("Ivan Ivanov");
            var customerCompany = new Company("Ivanov OOD");

            var accounts = new IAccount[]
            {
                new LoanAccount(customerIndividual, 10),
                new LoanAccount(customerCompany, 10),
                new MortgageAccount(customerIndividual, 10),
                new MortgageAccount(customerCompany, 10)
            };
            var depositAccount = new DepositAccount[]
            {
                new DepositAccount(customerIndividual, 10),
                new DepositAccount(customerCompany, 10),
            };

            foreach (var daccount in depositAccount)
            {
                Console.WriteLine("Test account");
                Console.WriteLine("-------------");
                Console.WriteLine(daccount);
                Console.WriteLine("Calling Deposit method. Result: {0}", daccount.Deposit(1000));
                Console.WriteLine("Calling Calculate Interest for Period 3 months. Result: {0}",
                    daccount.CallculatInterestForPeriod(3));
                Console.WriteLine("Calling Withdraw method. Result: {0}", daccount.Withdraw(200));
                Console.WriteLine("Calling Calculate Interest for Period 3 months. Result: {0}",
                   daccount.CallculatInterestForPeriod(3));
                Console.WriteLine("Calling Withdraw method. Result: {0}", daccount.Withdraw(801));
                Console.WriteLine();
            }
            foreach (var account in accounts)
            {
                Console.WriteLine("Test account");
                Console.WriteLine("-------------");
                Console.WriteLine(account);
                Console.WriteLine("Calling Deposit method. Result: {0}", account.Deposit(1000));
                Console.WriteLine("Calling Calculate Interest for Period 3 months. Result: {0}\n",
                    account.CallculatInterestForPeriod(3));
            }
        }