Ejemplo n.º 1
0
        static void Main()
        {
            Customer petar = new IndividualCustomer("Petar Gigov", "8412316466");
            Customer softUni = new CompanyCustomer("Software University", "BG25445644");
            Account petarDepositAccount = new DepositAccount(10000, 3.0m, petar);

            Console.WriteLine(petarDepositAccount.CalculateInterest(12).ToString("f2"));
            Console.WriteLine();

            Account petarLoanAccount = new LoanAccount(10000, 12m, petar);
            Console.WriteLine(petarLoanAccount.CalculateInterest(4).ToString("f2"));
            Account softuniLoanAccount = new LoanAccount(10000, 12m, softUni);
            Console.WriteLine(softuniLoanAccount.CalculateInterest(4).ToString("f2"));
            Console.WriteLine();

            Account petarMortgageAccount = new MortgageAccount(10000, 12m, petar);
            Console.WriteLine(petarMortgageAccount.CalculateInterest(12).ToString("f2"));
            Account softUniMortgageAccount = new MortgageAccount(10000, 12m, softUni);
            Console.WriteLine(softUniMortgageAccount.CalculateInterest(12).ToString("f2"));
            Console.WriteLine();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            ICustomer mitko         = new IndividualCustomer("Dimitar Obretenov");
            ICustomer alex          = new IndividualCustomer("Alex Petrov");
            ICustomer rosko         = new IndividualCustomer("Rostislav Savov");
            ICustomer bobi          = new IndividualCustomer("Boqna Ivailova");
            ICustomer nikeCompany   = new CompanyCustomer("Nike ltd.");
            ICustomer adidasCompany = new CompanyCustomer("Adidas ltd.");
            ICustomer pumaCompany   = new CompanyCustomer("Puma ltd.");

            IAccount mortgageAccIndividual     = new MortgageAccount(mitko, 5.5m, 1500m);
            IAccount mortgageAccCompany        = new MortgageAccount(nikeCompany, 6m, 3250m);
            IAccount loanAccIndividual         = new LoanAccount(alex, 6.1m, 5000m);
            IAccount loanAccCompany            = new LoanAccount(adidasCompany, 4.1m, 5000m);
            IAccount depositAccIndividualSmall = new DepositAccount(rosko, 4.5m, 970m);
            IAccount depositAccIndividualBig   = new DepositAccount(bobi, 5m, 1500m);
            IAccount depostAccCompany          = new DepositAccount(pumaCompany, 5.1m, 1700m);

            List <IAccount> accounts = new List <IAccount>()
            {
                mortgageAccIndividual,
                mortgageAccCompany,
                loanAccIndividual,
                loanAccCompany,
                depositAccIndividualBig,
                depositAccIndividualSmall,
                depostAccCompany
            };

            foreach (var account in accounts)
            {
                Console.Write("Type customer: {0}, ", account.Customer.GetType().Name);
                Console.WriteLine("Type account: {0}, ", account.GetType().Name);
                Console.WriteLine("Calculate interest rate for 2 months: {0}, ", account.CalculateInterestRate(2));
                Console.WriteLine("Calculate interest rate for 5 months: {0}, ", account.CalculateInterestRate(5));
                Console.WriteLine("Calculate interest rate for 7 months: {0}, ", account.CalculateInterestRate(7));
                Console.WriteLine("Calculate interest rate for 13 months: {0}, ", account.CalculateInterestRate(13));
                Console.WriteLine();
            }
        }
Ejemplo n.º 3
0
        public static void Main()
        {
            ICustomer pesho = new IndividualCustomer("Petar Petrov");
            ICustomer agroCompany = new CompanyCustomer("Agro Company Ltd.");

            IAccount mortgageAccInd = new MortgageAccount(pesho, 10024m, 5.3m);
            IAccount mortgageAccComp = new MortgageAccount(agroCompany, 10024m, 5.3m);
            IAccount loanAccInd = new LoanAccount(pesho, 1024m, 5.3m);
            IAccount loanAccComp = new LoanAccount(agroCompany, 10024m, 5.3m);
            IAccount depositAccIndBig = new DepositAccount(pesho, 10024m, 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);
            }
        }