Example #1
0
        static void Main()
        {
            Customer d1 = new Deposit(10000, new DateTime(2013, 1, 15), Enums.CustomerType.Companie, 6);
            Customer d2 = new Mortgage(2000, new DateTime(2016, 11, 9), Enums.CustomerType.Individual, 4);
            Customer d3 = new Loan(3000, new DateTime(2014, 11, 5), Enums.CustomerType.Individual, 5);
            Customer d4 = new Deposit(4500, new DateTime(2010, 7, 9), Enums.CustomerType.Companie, 5);


            List <Customer> customers = new List <Customer>();

            customers.Add(d1);
            customers.Add(d2);
            customers.Add(d3);
            customers.Add(d4);

            foreach (var item in customers)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("============================================================================");
            Console.WriteLine("Test the methods DrowMoney and DepositeMoney");
            Console.WriteLine("the customer before calling the methods");
            Console.WriteLine(d2.ToString());
            Console.WriteLine("----------------------------------------------------------------------------");
            d2.DrowMoney(1000);
            d2.DepositeMoney(1000);
            Console.WriteLine("the customer after the methods");
            Console.WriteLine(d2.ToString());
            Console.WriteLine("----------------------------------------------------------------------------");


            Console.WriteLine("the customer before calling the methods");
            Console.WriteLine(d1.ToString());
            Console.WriteLine("----------------------------------------------------------------------------");
            d1.DrowMoney(500);
            d1.DepositeMoney(1000);
            Console.WriteLine("the customer after the methods");
            Console.WriteLine(d1.ToString());
        }
Example #2
0
        static void Main()
        {
            // loan tests
            "Test1: Loan account".PrintDelimiter();
            Console.WriteLine("\nCreating individual loan account with 1500 deposit and 25 month interest...\n");
            Customer lili        = new Individual("Lili");
            Account  liliLoanAcc = new Loan(lili, 1500, 25);

            int months = 5;

            Console.WriteLine("Expected interest for {0} months: 750", months);
            Console.WriteLine("Returned: {0}", liliLoanAcc.CalcInterestAmount(months));

            months = 3;
            Console.WriteLine("Expected interest for {0} months: 0", months);
            Console.WriteLine("Returned: {0}", liliLoanAcc.CalcInterestAmount(months));


            Console.WriteLine("\nCreating company loan account with 500 deposit and 50 month interest...\n");
            Customer gbs            = new Company("GlavBulgarStroi");
            Account  GBSLoanAccount = new Loan(gbs, 500, 50);

            months = 3;
            Console.WriteLine("Expected interest for {0} months: 250", months);
            Console.WriteLine("Returned: {0}", GBSLoanAccount.CalcInterestAmount(months));

            months = 5;
            Console.WriteLine("Expected interest for {0} months: 750", months);
            Console.WriteLine("Returned: {0}", GBSLoanAccount.CalcInterestAmount(months));



            // deposits tests
            "Test2: Deposit account".PrintDelimiter();
            Console.WriteLine("Creating individual deposit account with 500 deposit and 20 month interest...\n");
            Account liliDeposit = new Deposit(lili, 500, 20);

            months = 8;
            Console.WriteLine("Expected interest for {0} months: 0", months);
            Console.WriteLine("Returned: {0}", liliDeposit.CalcInterestAmount(months));

            Console.WriteLine("\nDepositing 700 to individual`s Deposit account...\n");
            liliDeposit.Deposit(700);

            Console.WriteLine("Expected deposit balance: 1200");
            Console.WriteLine("Returned: {0}", liliDeposit.Balance);

            Console.WriteLine("Expected interest for {0} months: 1920", months);
            Console.WriteLine("Returned: {0}", liliDeposit.CalcInterestAmount(months));


            Console.WriteLine("\nCreating company deposit account with 1500 deposit and 20 month interest...\n");
            Deposit gbsDeposit = new Deposit(gbs, 1500, 20);

            months = 8;
            Console.WriteLine("Expected interest for {0} months: 2400", months);
            Console.WriteLine("Returned: {0}", gbsDeposit.CalcInterestAmount(months));

            Console.WriteLine("\nWithdrawing 700 from company deposit...\n");
            gbsDeposit.Withdraw(700);

            Console.WriteLine("Expected deposit balance: 800");
            Console.WriteLine("Returned: {0}", gbsDeposit.Balance);

            months = 8;
            Console.WriteLine("Expected interest for {0} months: 0", months);
            Console.WriteLine("Returned: {0}", gbsDeposit.CalcInterestAmount(months));



            // mortgage tests
            "Test3: Mortgage account".PrintDelimiter();
            Console.WriteLine("Creating individual mortgage account with 500 deposit and 20 month interest...\n");
            Account liliMortgage = new Mortgage(lili, 500, 20);

            months = 8;
            Console.WriteLine("Expected interest for {0} months: 200", months);
            Console.WriteLine("Returned: {0}", liliMortgage.CalcInterestAmount(months));

            months = 5;
            Console.WriteLine("Expected interest for {0} months: 0", months);
            Console.WriteLine("Returned: {0}", liliMortgage.CalcInterestAmount(months));

            Console.WriteLine("\nCreating company mortgage account with 1500 deposit and 30 month interest...\n");
            Account gbsMortgage = new Mortgage(gbs, 1500, 30);

            months = 8;
            Console.WriteLine("Expected interest for {0} months: 1800", months);
            Console.WriteLine("Returned: {0}", gbsMortgage.CalcInterestAmount(months));

            months = 13;
            Console.WriteLine("Expected interest for {0} months: 3150", months);
            Console.WriteLine("Returned: {0}", gbsMortgage.CalcInterestAmount(months));
        }
Example #3
0
        static void Main()
        {
            // loan tests
            "Test1: Loan account".PrintDelimiter();
            Console.WriteLine("\nCreating individual loan account with 1500 deposit and 25 month interest...\n");
            Customer lili = new Individual("Lili");
            Account liliLoanAcc = new Loan(lili, 1500, 25);

            int months = 5;
            Console.WriteLine("Expected interest for {0} months: 750", months);
            Console.WriteLine("Returned: {0}", liliLoanAcc.CalcInterestAmount(months));

            months = 3;
            Console.WriteLine("Expected interest for {0} months: 0", months);
            Console.WriteLine("Returned: {0}", liliLoanAcc.CalcInterestAmount(months));

            Console.WriteLine("\nCreating company loan account with 500 deposit and 50 month interest...\n");
            Customer gbs = new Company("GlavBulgarStroi");
            Account GBSLoanAccount = new Loan(gbs, 500, 50);

            months = 3;
            Console.WriteLine("Expected interest for {0} months: 250", months);
            Console.WriteLine("Returned: {0}", GBSLoanAccount.CalcInterestAmount(months));

            months = 5;
            Console.WriteLine("Expected interest for {0} months: 750", months);
            Console.WriteLine("Returned: {0}", GBSLoanAccount.CalcInterestAmount(months));

            // deposits tests
            "Test2: Deposit account".PrintDelimiter();
            Console.WriteLine("Creating individual deposit account with 500 deposit and 20 month interest...\n");
            Account liliDeposit = new Deposit(lili, 500, 20);

            months = 8;
            Console.WriteLine("Expected interest for {0} months: 0", months);
            Console.WriteLine("Returned: {0}", liliDeposit.CalcInterestAmount(months));

            Console.WriteLine("\nDepositing 700 to individual`s Deposit account...\n");
            liliDeposit.Deposit(700);

            Console.WriteLine("Expected deposit balance: 1200" );
            Console.WriteLine("Returned: {0}", liliDeposit.Balance);

            Console.WriteLine("Expected interest for {0} months: 1920", months);
            Console.WriteLine("Returned: {0}", liliDeposit.CalcInterestAmount(months));

            Console.WriteLine("\nCreating company deposit account with 1500 deposit and 20 month interest...\n");
            Deposit gbsDeposit = new Deposit(gbs, 1500, 20);

            months = 8;
            Console.WriteLine("Expected interest for {0} months: 2400", months);
            Console.WriteLine("Returned: {0}", gbsDeposit.CalcInterestAmount(months));

            Console.WriteLine("\nWithdrawing 700 from company deposit...\n");
            gbsDeposit.Withdraw(700);

            Console.WriteLine("Expected deposit balance: 800");
            Console.WriteLine("Returned: {0}", gbsDeposit.Balance);

            months = 8;
            Console.WriteLine("Expected interest for {0} months: 0", months);
            Console.WriteLine("Returned: {0}", gbsDeposit.CalcInterestAmount(months));

            // mortgage tests
            "Test3: Mortgage account".PrintDelimiter();
            Console.WriteLine("Creating individual mortgage account with 500 deposit and 20 month interest...\n");
            Account liliMortgage = new Mortgage(lili, 500, 20);

            months = 8;
            Console.WriteLine("Expected interest for {0} months: 200", months);
            Console.WriteLine("Returned: {0}", liliMortgage.CalcInterestAmount(months));

            months = 5;
            Console.WriteLine("Expected interest for {0} months: 0", months);
            Console.WriteLine("Returned: {0}", liliMortgage.CalcInterestAmount(months));

            Console.WriteLine("\nCreating company mortgage account with 1500 deposit and 30 month interest...\n");
            Account gbsMortgage = new Mortgage(gbs, 1500, 30);

            months = 8;
            Console.WriteLine("Expected interest for {0} months: 1800", months);
            Console.WriteLine("Returned: {0}", gbsMortgage.CalcInterestAmount(months));

            months = 13;
            Console.WriteLine("Expected interest for {0} months: 3150", months);
            Console.WriteLine("Returned: {0}", gbsMortgage.CalcInterestAmount(months));
        }