Esempio n. 1
0
 static void Main(string[] args)
 {
     LoanAccount myLoanAccount = new LoanAccount(10.6M, 4.5M, new Individual());
     Console.WriteLine(myLoanAccount.CalculateMonthlyInterest(12));
     MortgageAccount myMortgageAccount = new MortgageAccount(1000M, 2.7M, new Company());
     Console.WriteLine(myMortgageAccount.CalculateMonthlyInterest(14));
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            List <IAccount> accounts = new List <IAccount>();

            ICustomer person  = new Individual("Mihai Irimia", 1911122284548);
            ICustomer company = new Company("Polaris-Palmax", "1234RO436534");

            DateTime noOfDays = new DateTime(2018, 10, 3, 0, 0, 0);

            IAccount depositAccount  = new DepositAccount(person, 10000, 10, noOfDays); // noOfMonths = 4
            IAccount loanAccount     = new LoanAccount(company, 100, 5, noOfDays);
            IAccount mortgageAccount = new MortgageAccount(company, 1000, 10, noOfDays);

            accounts.Add(depositAccount);
            accounts.Add(loanAccount);
            accounts.Add(mortgageAccount);

            foreach (var elem in accounts)
            {
                elem.Print();
            }


            Console.ReadKey();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Account deposit1 = new DepositAccount(new Individual(), 500m, 3.5m);
            Account deposit2 = new DepositAccount(new Company(), 1500m, 3.4m);

            Console.WriteLine(deposit1.CalculateInterestAmount(2)); // 0
            Console.WriteLine(deposit2.CalculateInterestAmount(2)); // 6.8

            Account loan1 = new LoanAccount(new Individual(), 1000m, 5m);
            Account loan2 = new LoanAccount(new Company(), 1000m, 5m);

            Console.WriteLine(loan1.CalculateInterestAmount(2)); // 0
            Console.WriteLine(loan1.CalculateInterestAmount(4)); // 20
            Console.WriteLine(loan2.CalculateInterestAmount(1)); // 0
            Console.WriteLine(loan2.CalculateInterestAmount(3)); // 15

            Account mortgage1 = new MortgageAccount(new Individual(), 1000m, 5m);
            Account mortgage2 = new MortgageAccount(new Company(), 1000m, 5m);

            Console.WriteLine(mortgage2.CalculateInterestAmount(11)); // 65 / 2 = 27.5
            Console.WriteLine(mortgage2.CalculateInterestAmount(13)); // 65
            Console.WriteLine(mortgage1.CalculateInterestAmount(5));  // 0
            Console.WriteLine(mortgage1.CalculateInterestAmount(7));  // 35

            Individual customer1 = new Individual("Pesho");
            Company    customer2 = new Company("Telerik");

            Console.WriteLine(customer1.Name); // Pesho
            Console.WriteLine(customer2.Name); // Telerik
        }
Esempio n. 4
0
        /*2.	A bank holds different types of accounts for its customers:
         * deposit accounts, loan accounts and mortgage accounts. Customers could be individuals or companies.*/
        /*All accounts have customer, balance and interest rate (monthly based).
         * Deposit accounts are allowed to deposit and with draw money.
         * Loan and mortgage accounts can only deposit money.*/
        /*All accounts can calculate their interest amount for a given period (in months).
         * In the common case its is calculated as follows: number_of_months * interest_rate.*/
        /*Loan accounts have no interest for the first 3 months
         * if are held by individuals and for the first 2 months if are held by a company.*/
        /* Deposit accounts have no interest if their balance is positive and less than 1000. */
        /* Mortgage accounts have ½ interest for the first 12 months for companies and no interest for the first 6 months for individuals.*/
        static void Main()
        {
            //create customers
            Person person = new Person("Tervel", "Kubratov", "Sofia");
            Person someone = new Person("King", "Arthur", "Dublin");
            Company company = new Company("Tervel OOD", "Sofia", TypeOfFirm.LTD);

            //create aacounts, interest 3% = 0.03M
            DepositAccount depositPerson = new DepositAccount(person, 450.00M, 0.03M, 4);
            depositPerson.Balance = depositPerson.DepositeMoney(2400M);
            Console.WriteLine("Balance of {0} is {1:C3}", person.FirstName, depositPerson.Balance);
            Console.WriteLine("Interest Amount of deposit {0} is {1}", person.FirstName, depositPerson.CalculateInterestAmount());
            LoanAccount loanPerson = new LoanAccount(person, 3200.0M, 0.04M, 13);
            Console.WriteLine("Interest Amount of loan {0} is {1}", person.FirstName, loanPerson.CalculateInterestAmount());
            MortgageAccount mortgagePerson = new MortgageAccount(person, 5060.80M, 0.05M, 14);
            Console.WriteLine("Interest Amount of mortgage {0} is {1}", person.FirstName, mortgagePerson.CalculateInterestAmount());

            Console.WriteLine();
            DepositAccount depositSomeone = new DepositAccount(someone, 3000.50M, 0.023M, 2);
            Console.WriteLine("Balance of {0} is {1:C3}", someone.FirstName, depositSomeone.Balance);

            Console.WriteLine();
            DepositAccount depositSome = new DepositAccount(company, 500.0M, 0.07M, 5);
            Console.WriteLine("Balance of \"{0}\" is {1:C3}", company.CompanyName, depositSome.Balance);
            Console.WriteLine("Interest Amount of deposit {0} is {1}", company.CompanyName, depositSome.CalculateInterestAmount());
            MortgageAccount mortgageCompany = new MortgageAccount(company, 2500.00M, 0.05M, 13);
            Console.WriteLine("Interest Amount of mortgage {0} is {1}", company.CompanyName, mortgageCompany.CalculateInterestAmount());
        }
Esempio n. 5
0
        static void Main()
        {
            //do some test when you check my homework, but i assure you that it works!!!
            MortgageAccount account = new MortgageAccount
            (new IndividualCustomer("Kris", "23"), 4000, 0.02);

            Console.WriteLine(account.InterestAmount(15));
        }
        public static void Main()
        {
            LoanAccount     lAccount = new LoanAccount("Gosho Goshev", CustomerTypes.individual, 23423, 3);
            DepositAccount  dAccount = new DepositAccount("Company", CustomerTypes.company, 44321, 1.75m);
            MortgageAccount mAccount = new MortgageAccount("Any individual", CustomerTypes.individual, -234, 2.99m);

            Console.WriteLine("Loan account interest amont for 5 months: {0}", lAccount.InterestAmount(5));
            Console.WriteLine("Deposit account interest amont for 3 months: {0}", dAccount.InterestAmount(3));
            Console.WriteLine("Mortgage account interest amont for 7 months: {0}", mAccount.InterestAmount(7));
        }
Esempio n. 7
0
        static void Main()
        {
            Individual ivo   = new Individual("Ivo", "Dimov", "Sofia");
            Company    compy = new Company("Tech OOD", "Sofia");

            var firstMorg = new MortgageAccount(ivo, 200, 4);
            var secMorg   = new MortgageAccount(compy, 300, 4);

            Console.WriteLine(firstMorg.CalculateInterestAmount(4));   // 0
            Console.WriteLine(secMorg.CalculateInterestAmount(4));     // 16/2 = 8

            var firstLoan = new LoanAccount(ivo, 200, 4);
            var secLoan   = new LoanAccount(compy, 300, 4);

            Console.WriteLine(firstLoan.CalculateInterestAmount(4));   // 1 month * 4 = 4
            Console.WriteLine(secLoan.CalculateInterestAmount(4));     // 2 months * 4 = 8
        }
        static void Main(string[] args)
        {
            List<Account> accounts = new List<Account>
            {
                new DepositAccount(new Individual("Petar Petrov"), 1000,0.02),
                new DepositAccount(new Company("CompanyLTD"), 15000,0.02),
                new DepositAccount(new Individual("Maria Petrova"), 1500,0.05),
                new MortgageAccount(new Company("CompanyLTD"), 50000,0.04),
                new MortgageAccount(new Individual("Maria Petrova"), 35000,0.06),
                new LoanAccount(new Company("CompanyLTD"), 7000,0.08),
                new DepositAccount(new Individual("Maria Petrova"), 1500,0.0012),
            };

            Bank Investbank = new Bank(accounts);

            MortgageAccount testPersonalAccount = new MortgageAccount(new Individual("Marcheto"), 1200, 0.02);
            Console.WriteLine(testPersonalAccount.CalculateInterest(24));
        }
Esempio n. 9
0
        static void Main()
        {
            var bajPesho    = Customer.Individual;
            var leliaMarche = Customer.Individual;
            var mrAnderson  = Customer.Individual;

            var google    = Customer.Company;
            var microsoft = Customer.Company;
            var facebook  = Customer.Company;

            var bajPeshoAccount    = new DepositAccount(bajPesho, 200, 7);
            var leliaMarcheAccount = new MortgageAccount(leliaMarche, 200, 7);
            var mrAndersonAccount  = new LoanAccount(mrAnderson, 200, 7);

            var googleAccount    = new DepositAccount(google, 200, 7);
            var microsoftAccount = new MortgageAccount(microsoft, 200, 7);
            var facebookAccount  = new LoanAccount(facebook, 200, 7);

            googleAccount.Withdraw(100);
            // Console.WriteLine(googleAccount.Balance);
            facebookAccount.Deposit(100);
            // Console.WriteLine(facebookAccount.Balance);

            var accounts = new List <IAccount>()
            {
                googleAccount,
                microsoftAccount,
                facebookAccount,
                bajPeshoAccount,
                leliaMarcheAccount,
                mrAndersonAccount
            };

            var sortedAccounts = accounts.OrderByDescending(account => account.Balance);

            foreach (var account in sortedAccounts)
            {
                decimal interestFirstMonths = account.CalculateInterest(3);
                decimal interest            = account.CalculateInterest(13);

                Console.WriteLine("customer: {0} - balance: {1}; first months interest: {2}; interest: {3}"
                                  , account.Customer, account.Balance, interestFirstMonths, interest);
            }
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            var b = new Bank("ING");

            var c1 = new Individual();

            var d = new DepositAccount(b, c1, 1000, 3.85m, 12);

            Console.WriteLine(d.CalculateInterest());


            var l = new LoanAccount(b, c1, 1000, 3.5m, 12);

            Console.WriteLine(l.CalculateInterest());

            var c2 = new Company();
            var m  = new MortgageAccount(b, c2, 1500, 3.8m, 36);

            Console.WriteLine(m.CalculateInterest());
        }
Esempio n. 11
0
        public static void Main()
        {
            DepositAccount kiro = new DepositAccount(Customers.Individual, 1000m, 5);
            Console.WriteLine(kiro.CalculateInterest(10) + "\n");

            LoanAccount pesho = new LoanAccount(Customers.Individual, 1500m, 3);
            Console.WriteLine(pesho.CalculateInterest(12) + "\n");

            LoanAccount maglaOOD = new LoanAccount(Customers.Company, 1500m, 3);
            Console.WriteLine(maglaOOD.CalculateInterest(12) + "\n");

            MortgageAccount penka = new MortgageAccount(Customers.Individual, 50000m, 2);
            Console.WriteLine(penka.CalculateInterest(8) + "\n");

            MortgageAccount shadyAD = new MortgageAccount(Customers.Company, 250000m, 5);
            Console.WriteLine(penka.CalculateInterest(12) + "\n");

            MortgageAccount shadyOOD = new MortgageAccount(Customers.Company, 250000m, 5);
            Console.WriteLine(penka.CalculateInterest(24) + "\n");
        }
Esempio n. 12
0
        static void Main()
        {
            DepositAccount depositPersonAcc = new DepositAccount(Customer.Individual, 10000.00M, 2.5);

            Console.WriteLine("Individual deposit account(balance = {0}) interest for 12 months = {1:F2}."
                              , depositPersonAcc.Balance, depositPersonAcc.CalculateInterest(12));
            Console.WriteLine("Withdrawing from this account 9500.");
            depositPersonAcc.Withdraw(9500);
            Console.WriteLine("Individual deposit account(balance = {0}) interest for 12 months = {1:F2}."
                              , depositPersonAcc.Balance, depositPersonAcc.CalculateInterest(12));
            Console.WriteLine("Try to withdraw 501.");
            depositPersonAcc.Withdraw(501);

            LoanAccount loanPersonAcc  = new LoanAccount(Customer.Individual, -15250.35M, 2.0);
            LoanAccount loanCompanyAcc = new LoanAccount(Customer.Company, -50000, 1.5);

            Console.WriteLine("\nIndividual loan account(balance = {0}) interest for 3 months = {1:F2}."
                              , loanPersonAcc.Balance, loanPersonAcc.CalculateInterest(3));
            Console.WriteLine("Individual loan account(balance = {0}) interest for 10 months = {1:F2}."
                              , loanPersonAcc.Balance, loanPersonAcc.CalculateInterest(10));
            Console.WriteLine("Company loan account(balance = {0}) interest for 10 months = {1:F2}."
                              , loanCompanyAcc.Balance, loanCompanyAcc.CalculateInterest(10));
            Console.WriteLine("Company loan account(balance = {0}) interest for 2 months = {1:F2}."
                              , loanCompanyAcc.Balance, loanCompanyAcc.CalculateInterest(2));

            MortgageAccount mortgagePersonAcc  = new MortgageAccount(Customer.Individual, -2500.50M, 3.2);
            MortgageAccount mortgageCompanyAcc = new MortgageAccount(Customer.Company, -1000M, 1);

            Console.WriteLine("\nIndividual mortgage account(balance = {0}) interest for 6 months = {1:F2}."
                              , mortgagePersonAcc.Balance, mortgagePersonAcc.CalculateInterest(6));
            Console.WriteLine("Individual mortgage account(balance = {0}) interest for 10 months = {1:F2}."
                              , mortgagePersonAcc.Balance, mortgagePersonAcc.CalculateInterest(10));
            Console.WriteLine("Individual mortgage account(balance = {0}) interest for 12 months = {1:F2}."
                              , mortgageCompanyAcc.Balance, mortgageCompanyAcc.CalculateInterest(12)); //for first 12 months interest is 60$
            Console.WriteLine("Individual mortgage account(balance = {0}) interest for 24 months = {1:F2}."
                              , mortgageCompanyAcc.Balance, mortgageCompanyAcc.CalculateInterest(24)); //for 24 months interest is 60$ for first 12months + 120$ for next 12 months
        }
Esempio n. 13
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);
            }
        }