Exemple #1
0
        static void Main()
        {
            IndividualCustomer individualCustomer1 = new IndividualCustomer("Peter Johnson");
            CompanyCustomer companyCustomer1 = new CompanyCustomer("Telerik");
            Account[] accounts = {
                new DepositAccount(individualCustomer1, 2345M, 0.4M),
                new MortgageAccount(individualCustomer1, -230000M, 0.5M),
                new LoanAccount(companyCustomer1, -1000000M, 0.2M)
            };

            foreach (Account account in accounts)
            {
                Console.WriteLine("The year interest is: {0:P}", account.CalculateInterest(12));
            }

            Console.WriteLine(new string('=', 40));

            Console.WriteLine("Balance: {0}", accounts[0].Balance);
            accounts[0].Deposit(200m);
            Console.WriteLine("Balance after deposit: {0}", accounts[0].Balance);
            (accounts[0] as DepositAccount).Withdraw(50m);
            Console.WriteLine("Balance after withdraw: {0}", accounts[0].Balance);

            Console.WriteLine("Balance: {0}", accounts[1].Balance);
            accounts[1].Deposit(1000m);
            Console.WriteLine("Balance after deposit: {0}", accounts[1].Balance);
        }
Exemple #2
0
        public void TestCustomerConstructor5()
        {
            Customer customer = new IndividualCustomer(
                "2343PJ34752",
                "William",
                "Harris",
                "1 Microsoft Way, Redmond, WA",
                "1-888-553-6562");

            Assert.AreEqual("1-888-553-6562", customer.Phone);
        }
Exemple #3
0
        public void TestAccountConstructor1()
        {
            Customer accountCustomer = new IndividualCustomer(
                "2343PJ34752",
                "William",
                "Harris",
                "1 Microsoft Way, Redmond, WA",
                "1-888-553-6562");

            Account account = new DepositAccount(
                accountCustomer,
                2500,
                1.0825M,
                12);

            Assert.AreEqual(2500, account.Balance);
        }
Exemple #4
0
        static void Main()
        {
            CompanyCustomer    company     = new CompanyCustomer("X OOD");
            IndividualCustomer individual  = new IndividualCustomer("Ivan Petrov", 21);
            IndividualCustomer individual2 = new IndividualCustomer("Ivan Petrov", 16);

            Account[] accounts =
            {
                new Deposit(individual,    1500,  5, 12),
                new Loan(company,         50000,  5,  6),
                new Mortgage(individual2, 75000, 10, 24),
            };

            foreach (var account in accounts)
            {
                Console.WriteLine(account);
                Console.WriteLine();
                Console.WriteLine("{0}", new string('-', 40));
                Console.WriteLine();
            }
        }
Exemple #5
0
        static void Main()
        {
            CompanyCustomer company = new CompanyCustomer("X OOD");
            IndividualCustomer individual = new IndividualCustomer("Ivan Petrov", 21);
            IndividualCustomer individual2 = new IndividualCustomer("Ivan Petrov", 16);

            Account[] accounts =
            {
                new Deposit(individual, 1500, 5, 12),
                new Loan(company, 50000, 5, 6),
                new Mortgage(individual2, 75000, 10, 24),
            };

            foreach (var account in accounts)
            {
                Console.WriteLine(account);
                Console.WriteLine();
                Console.WriteLine("{0}", new string('-', 40));
                Console.WriteLine();
            }
        }
Exemple #6
0
        public static void Main()
        {
            Customer misho   = new IndividualCustomer("Misho Mishev", 7409128991);
            Customer actavis = new CompanyCustomer("Actavis", "BG9863535399");

            var accounts = new List <Account>()
            {
                new DepositAccount(misho, 2999.99m, 3.5),
                new LoanAccount(misho, 2999.99m, 4.0),
                new MortgageAccount(misho, 2999.99m, 1.5),
                new DepositAccount(actavis, 3000000.50m, 4.5),
                new LoanAccount(actavis, 3000000.50m, 5.0),
                new MortgageAccount(actavis, 3000000.50m, 2.5)
            };

            foreach (var account in accounts)
            {
                Console.WriteLine("--Customer:{0}--\nBalance: {1}\n {2} -> 3 months interest: {3}; 24 months interest: {4}",
                                  account.Customer.Name, account.Balance, account.GetType().Name, account.CalculateInterest(3), account.CalculateInterest(24));
            }
        }
Exemple #7
0
        public static void Main()
        {
            ICustomer pesho       = new IndividualCustomer("Petar Petrov");
            ICustomer agroCompany = new CompanyCustomer("Agro Company Ltd.");

            IAccount mortgageAccInd     = new MortgageAccount(pesho, 1024m, 5.3m);
            IAccount mortgageAccComp    = new MortgageAccount(agroCompany, 1024m, 5.3m);
            IAccount loanAccInd         = new LoanAccount(pesho, 1024m, 5.3m);
            IAccount loanAccComp        = new LoanAccount(agroCompany, 1024m, 5.3m);
            IAccount depositAccIndBig   = new DepositAccount(pesho, 1024m, 5.3m);
            IAccount depositAccIndSmall = new DepositAccount(pesho, 999m, 5.3m);
            IAccount depositAccComp     = new DepositAccount(agroCompany, 11024m, 4.3m);

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

            foreach (var acc in accounts)
            {
                Console.WriteLine(
                    "{5} {0,-15}: {1:N2}, {2:N2}, {3:N2}, {4:N2}",
                    acc.GetType().Name,
                    acc.CalculateRate(2),
                    acc.CalculateRate(3),
                    acc.CalculateRate(10),
                    acc.CalculateRate(13),
                    acc.Customer.GetType().Name);
            }
        }
        static void Main(string[] args)
        {
            ICustomer pesho = new IndividualCustomer("Pesho Peshkov");
            ICustomer apple = new CompanyCustomer("Qbalka");

            IAccount mortgageAccInd = new MortgageAccount(pesho, 1024m, 5.3m);
            IAccount mortgageAccComp = new MortgageAccount(apple, 1024m, 5.3m);
            IAccount loanAccInd = new LoanAccount(pesho, 1024m, 5.3m);
            IAccount loanAccComp = new LoanAccount(apple, 1024m, 5.3m);
            IAccount depositAccIndBig = new DepositAccount(pesho, 1024m, 5.3m);
            IAccount depositAccIndSmall = new DepositAccount(pesho, 999m, 5.3m);
            IAccount depositAccComp = new DepositAccount(apple, 11024m, 4.3m);

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

            foreach (var acc in accounts)
            {
                Console.WriteLine(
                    "{5} {0,-15}: {1:N2}, {2:N2}, {3:N2}, {4:N2}",
                    acc.GetType().Name,
                    acc.CalculateRate(2),
                    acc.CalculateRate(3),
                    acc.CalculateRate(10),
                    acc.CalculateRate(13),
                    acc.Customer.GetType().Name);
            }
        }
Exemple #9
0
        public void TestDepositMethod()
        {
            Customer accountCustomer = new IndividualCustomer(
                "2343PJ34752",
                "William",
                "Harris",
                "1 Microsoft Way, Redmond, WA",
                "1-888-553-6562");

            Account account = new DepositAccount(
                accountCustomer,
                32500,
                1.0825M,
                12);

            account.Deposit(459M);

            Assert.AreEqual(32959M, account.Balance);
        }
Exemple #10
0
        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);
        }
Exemple #11
0
        public void TestAccountConstructor4_ThrowsException()
        {
            Customer accountCustomer = new IndividualCustomer(
                "2343PJ34752",
                "William",
                "Harris",
                "1 Microsoft Way, Redmond, WA",
                "1-888-553-6562");

            Account account = new DepositAccount(
                accountCustomer,
                2500,
                -1.0825M,
                12);
        }