Beispiel #1
0
        static void Main(string[] args)
        {
            DepositAccount  depositAcc1  = new DepositAccount(new CompanyCustomer(), 10000, 7.0);
            DepositAccount  depositAcc2  = new DepositAccount(new IndividualCustomer(), 1000, 8.0);
            LoanAccount     loanAcc1     = new LoanAccount(new CompanyCustomer(), 10000, 7.0);
            LoanAccount     loanAcc2     = new LoanAccount(new IndividualCustomer(), 1000, 8.0);
            MortgageAccount mortgageAcc1 = new MortgageAccount(new CompanyCustomer(), 10000, 7.0);
            MortgageAccount mortgageAcc2 = new MortgageAccount(new IndividualCustomer(), 1000, 8.0);

            Console.WriteLine(depositAcc1.CalculateInterestForAPeriod(10));
            Console.WriteLine(depositAcc2.CalculateInterestForAPeriod(10));
            Console.WriteLine(loanAcc1.CalculateInterestForAPeriod(2));
            Console.WriteLine(loanAcc1.CalculateInterestForAPeriod(4));
            Console.WriteLine(loanAcc2.CalculateInterestForAPeriod(3));
            Console.WriteLine(loanAcc2.CalculateInterestForAPeriod(6));
            Console.WriteLine(mortgageAcc1.CalculateInterestForAPeriod(12));
            Console.WriteLine(mortgageAcc1.CalculateInterestForAPeriod(14));
            Console.WriteLine(mortgageAcc2.CalculateInterestForAPeriod(6));
            Console.WriteLine(mortgageAcc2.CalculateInterestForAPeriod(8));
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Customer petya   = new Customer("Petya Cocheva", "individual");
            Customer dimitar = new Customer("Dimitar Cochev", "individual");
            Customer zara    = new Customer("Zara Cocheva", "individual");
            Customer btk     = new Customer("BTK", "company");
            Customer mtel    = new Customer("Mtel", "company");
            Customer telenor = new Customer("Telenor", "company");

            DepositAccount petyaDeposit   = new DepositAccount(petya, 555, 0.005);
            DepositAccount demitarDeposit = new DepositAccount(dimitar, 2000, 0.0005);

            LoanAccount zaraLoan = new LoanAccount(zara, 100, 0.0001);
            LoanAccount btkLoan  = new LoanAccount(btk, 10000, 0.0002);

            MortgageAccount dimitaMortgage  = new MortgageAccount(dimitar, 100000, 0.001);
            MortgageAccount telenorMortgage = new MortgageAccount(telenor, 20000000, 0.00012);

            Console.WriteLine("{0}, Customer:{1}, Balance:{2}, Term:{3}, EndBalance:{4}", petyaDeposit.GetType().Name, petyaDeposit.Customer.ToString(), petyaDeposit.Balance, 12, petyaDeposit.CalculateEndBalance(12));
            petyaDeposit.DepositMoney(500);
            Console.WriteLine("{0}, Customer:{1}, Balance:{2}, Term:{3}, EndBalance:{4}", petyaDeposit.GetType().Name, petyaDeposit.Customer.ToString(), petyaDeposit.Balance, 12, petyaDeposit.CalculateEndBalance(12));
            petyaDeposit.WithdrawMoney(1000);
            Console.WriteLine("{0}, Customer:{1}, Balance:{2}, Term:{3}, EndBalance:{4}", petyaDeposit.GetType().Name, petyaDeposit.Customer.ToString(), petyaDeposit.Balance, 12, petyaDeposit.CalculateEndBalance(12));
            Console.WriteLine("{0}, Customer:{1}, Balance:{2}, Term:{3}, EndBalance:{4}", demitarDeposit.GetType().Name, demitarDeposit.Customer.ToString(), demitarDeposit.Balance, 12, demitarDeposit.CalculateEndBalance(12));
            Console.WriteLine();

            Console.WriteLine("{0}, Customer:{1}, Balance:{2}, Term:{3}, EndBalance:{4}", zaraLoan.GetType().Name, zaraLoan.Customer.ToString(), zaraLoan.Balance, 3, zaraLoan.CalculateEndBalance(3));
            zaraLoan.DepositMoney(1000);
            Console.WriteLine("{0}, Customer:{1}, Balance:{2}, Term:{3}, EndBalance:{4}", zaraLoan.GetType().Name, zaraLoan.Customer.ToString(), zaraLoan.Balance, 3, zaraLoan.CalculateEndBalance(3));
            Console.WriteLine("{0}, Customer:{1}, Balance:{2}, Term:{3}, EndBalance:{4}", zaraLoan.GetType().Name, zaraLoan.Customer.ToString(), zaraLoan.Balance, 4, zaraLoan.CalculateEndBalance(4));
            Console.WriteLine("{0}, Customer:{1}, Balance:{2}, Term:{3}, EndBalance:{4}", btkLoan.GetType().Name, btkLoan.Customer.ToString(), btkLoan.Balance, 2, btkLoan.CalculateEndBalance(2));
            Console.WriteLine("{0}, Customer:{1}, Balance:{2}, Term:{3}, EndBalance:{4}", btkLoan.GetType().Name, btkLoan.Customer.ToString(), btkLoan.Balance, 3, btkLoan.CalculateEndBalance(3));
            Console.WriteLine();

            Console.WriteLine("{0}, Customer:{1}, Balance:{2}, Term:{3}, EndBalance:{4}", dimitaMortgage.GetType().Name, dimitaMortgage.Customer.ToString(), dimitaMortgage.Balance, 5, dimitaMortgage.CalculateEndBalance(5));
            Console.WriteLine("{0}, Customer:{1}, Balance:{2}, Term:{3}, EndBalance:{4}", dimitaMortgage.GetType().Name, dimitaMortgage.Customer.ToString(), dimitaMortgage.Balance, 7, dimitaMortgage.CalculateEndBalance(7));
            Console.WriteLine("{0}, Customer:{1}, Balance:{2}, Term:{3}, EndBalance:{4}", telenorMortgage.GetType().Name, telenorMortgage.Customer.ToString(), telenorMortgage.Balance, 12, telenorMortgage.CalculateEndBalance(12));
            Console.WriteLine("{0}, Customer:{1}, Balance:{2}, Term:{3}, EndBalance:{4}", telenorMortgage.GetType().Name, telenorMortgage.Customer.ToString(), telenorMortgage.Balance, 13, telenorMortgage.CalculateEndBalance(13));
        }
Beispiel #3
0
        public static void Main()
        {
            ICustomer gosho = new IndividualCustomer("Gosho Ivanov");
            ICustomer taoCompany = new CompanyCustomer("Tao Company ");

            IAccount mortgageAccInd = new MortgageAccount(gosho, 1000m, 3m);
            IAccount mortgageAccComp = new MortgageAccount(taoCompany, 2024, 5.3m);
            IAccount loanAccInd = new LoanAccount(gosho, 1000, 5.3m);
            IAccount loanAccComp = new LoanAccount(taoCompany, 2024, 8.3m);
            IAccount depositAccIndBig = new DepositAccount(gosho, 124, 5.3m);
            IAccount depositAccIndSmall = new DepositAccount(gosho, 599m, 3.3m);
            IAccount depositAccComp = new DepositAccount(taoCompany, 100, 2.3m);

            List<IAccount> accounts = new List<IAccount>()
            {
                mortgageAccInd,
                mortgageAccComp,
                loanAccInd,
                loanAccComp,
                depositAccIndBig,
                depositAccIndSmall,
                depositAccComp
            };

            foreach (var acc in accounts)
            {
                Console.WriteLine(
                    "{5} {0}: {1:N2}, {2:N2}, {3:N2}, {4:N2}",
                    acc.GetType().Name,
                    acc.CalculateRate(64),
                    acc.CalculateRate(3),
                    acc.CalculateRate(1),
                    acc.CalculateRate(4),
                    acc.Customer.GetType().Name);
            }
        }