Esempio n. 1
0
        static void Main()
        {
            DepositAccount  depositAccount        = new DepositAccount(new Customer("Pesho", "individual"), 1200m, 10m);
            DepositAccount  companyDepositAccount = new DepositAccount(new Customer("Goshos", "company"), 160000m, 8m);
            LoanAccount     loanAccount           = new LoanAccount(new Customer("Gosho", "individual"), 8000m, 12m);
            MortgageAccount morgageAccount        = new MortgageAccount(new Customer("Peshovi", "company"), 12000m, 16m);

            Console.WriteLine("Deposit balanse: " + depositAccount.Balance);
            depositAccount.Deposit(1000);
            Console.WriteLine("After deposit 1000: " + depositAccount.Balance);
            depositAccount.Withdraw(1200);
            Console.WriteLine("After withdraw 1200: " + depositAccount.Balance);
            Console.WriteLine();

            Console.WriteLine("Loan balanse: " + loanAccount.Balance);
            loanAccount.Deposit(1000);
            Console.WriteLine("After deposit 1000: " + loanAccount.Balance);
            Console.WriteLine();

            Console.WriteLine("Morgage balanse: " + morgageAccount.Balance);
            morgageAccount.Deposit(1000);
            Console.WriteLine("After deposit 1000: " + morgageAccount.Balance);
            Console.WriteLine();

            Console.WriteLine("Diderent interest calculations: ");
            Console.WriteLine(depositAccount.CalculateInterest(5));
            Console.WriteLine(depositAccount.CalculateInterest(5));
            Console.WriteLine(loanAccount.CalculateInterest(3));
            Console.WriteLine(loanAccount.CalculateInterest(4));
            Console.WriteLine(morgageAccount.CalculateInterest(6));
            Console.WriteLine(morgageAccount.CalculateInterest(7));
            Console.WriteLine(companyDepositAccount.CalculateInterest(12));
            Console.WriteLine(companyDepositAccount.CalculateInterest(13));
        }
        internal static void Main()
        {
            LoanAccount georgiIvanov = new LoanAccount(Customers.Individual, 9000M, 0.01M);
            LoanAccount bulSoft = new LoanAccount(Customers.Company, 50000M, 0.01M);
            Console.Write("Individual Deposit: " + georgiIvanov.Balance + " -> ");
            georgiIvanov.DepositMoney(1000M);
            Console.WriteLine("{0:0.00} has interest: {1:0.00}", georgiIvanov.Balance, georgiIvanov.CalcInterest(24));
            Console.Write("Company Deposit: " + bulSoft.Balance + " -> ");
            bulSoft.DepositMoney(10000M);
            Console.WriteLine("{0:0.00} has interest: {1:0.00}", bulSoft.Balance, bulSoft.CalcInterest(24));

            DepositAccount ivanIvanov = new DepositAccount(Customers.Individual, 2500M, 0.01M);
            DepositAccount ivanGeorgiev = new DepositAccount(Customers.Individual, 1500M, 0.01M);
            Console.Write("Individual Deposit: " + ivanIvanov.Balance + " -> ");
            ivanIvanov.DepositMoney(1000M);
            Console.WriteLine("{0:0.00} has interest: {1:0.00}", ivanIvanov.Balance, ivanIvanov.CalcInterest(12));
            Console.Write("Individual Withdraw: " + ivanGeorgiev.Balance + " -> ");
            ivanGeorgiev.WithdrawMoney(250M);
            Console.WriteLine("{0:0.00} has interest: {1:0.00}", ivanGeorgiev.Balance, ivanGeorgiev.CalcInterest(12));

            MortgageAccount maria = new MortgageAccount(Customers.Individual, 12500M, 0.01M);
            MortgageAccount georgievi = new MortgageAccount(Customers.Company, 31500M, 0.01M);
            Console.Write("Individual Deposit: " + maria.Balance + " -> ");
            maria.DepositMoney(1000M);
            Console.WriteLine("{0:0.00} has interest: {1:0.00}", maria.Balance, maria.CalcInterest(12));
            Console.Write("Company Deposit: " + georgievi.Balance + " -> ");
            georgievi.DepositMoney(250M);
            Console.WriteLine("{0:0.00} has interest: {1:0.00}", georgievi.Balance, georgievi.CalcInterest(12));
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Customer petar   = new IndividualCustomer("Petar Gigov", "8412316466");
            Customer softUni = new CompanyCustomer("Software University", "BG25445644");

            Account petarDepositAccount = new DepositAccount(petar, 1000m, 3.0m);

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

            Account petarLoanAccount = new LoanAccount(petar, 10000m, 12m);

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

            Console.WriteLine(softuniLoanAccount.CalculateInterest(4).ToString("f2"));
            Console.WriteLine();

            Account petarMortgageAccount = new MortgageAccount(petar, 10000m, 12m);

            Console.WriteLine(petarMortgageAccount.CalculateInterest(12).ToString("f2"));
            Account softUniMortgageAccount = new MortgageAccount(softUni, 10000m, 12m);

            Console.WriteLine(softUniMortgageAccount.CalculateInterest(12).ToString("f2"));
            Console.WriteLine();
        }
Esempio n. 4
0
        static void Main()
        {
            Console.WriteLine("DEPOSIT ACCOUNT");
            DepositAccount depositAccount = new DepositAccount(Customer.Companies, 5000.50m, 4.5m);

            Console.WriteLine(depositAccount.InterestRateForAPeriodCalculation(5));
            Console.WriteLine(depositAccount.Balance);
            depositAccount.Deposit(1000m);
            Console.WriteLine(depositAccount.Balance);
            Console.WriteLine(depositAccount.InterestRateForAPeriodCalculation(5));
            depositAccount.Widthraw(5500m);
            Console.WriteLine(depositAccount.Balance);
            Console.WriteLine(depositAccount.InterestRateForAPeriodCalculation(5));
            Console.WriteLine();

            Console.WriteLine("LOAN ACCOUNT");
            LoanAccount loanAccount = new LoanAccount(Customer.Individual, 5000, 10);

            Console.WriteLine(loanAccount.InterestRateForAPeriodCalculation(3));

            loanAccount.Customer = Customer.Companies;
            Console.WriteLine(loanAccount.InterestRateForAPeriodCalculation(3));
            Console.WriteLine();

            Console.WriteLine("MORTGAGE ACCOUNT");
            MortgageAccount mortgageAccount = new MortgageAccount(Customer.Companies, 4000m, 5.45m);

            Console.WriteLine(mortgageAccount.InterestRateForAPeriodCalculation(6));
        }
Esempio n. 5
0
 static void Main(string[] args)
 {
     Accounts loan = new Loan(7000, new Companies("Nike"), 0.09);
     loan.Deposit(600);
     Accounts deposit = new DepositAccount(1500, new IndividualCustomer("Gosho"), 0.12);
     deposit.Deposit(200);
     Accounts mortgage = new Mortgage(5000, new Companies("Puma"), 0.12);
     mortgage.Deposit(6000);
     Console.WriteLine(loan.CalculateRate(3));
     Console.WriteLine(mortgage.CalculateRate(15));
     Console.WriteLine(deposit.CalculateRate(10));
 }
Esempio n. 6
0
        static void Main(string[] args)
        {
            Accounts loan = new Loan(7000, new Companies("Nike"), 0.09);

            loan.Deposit(600);
            Accounts deposit = new DepositAccount(1500, new IndividualCustomer("Gosho"), 0.12);

            deposit.Deposit(200);
            Accounts mortgage = new Mortgage(5000, new Companies("Puma"), 0.12);

            mortgage.Deposit(6000);
            Console.WriteLine(loan.CalculateRate(3));
            Console.WriteLine(mortgage.CalculateRate(15));
            Console.WriteLine(deposit.CalculateRate(10));
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            Customer     pesho = new IndividualPerson("Pesho Peshev");
            Customer     globalEntertainmentOOD = new Company("Global Entertainment LTD");
            IAccountable depositAcc             = new DepositAccount(pesho, 2000m, 1.7d);
            IAccountable loanAcc    = new LoanAccount(pesho, 5000, 5.5d);
            IAccountable mortageAcc = new MortageAccount(globalEntertainmentOOD, 100000, 2.3d);

            IList <IAccountable> accounts = new List <IAccountable>()
            {
                depositAcc, loanAcc, mortageAcc
            };

            depositAcc.CalculateInterest(8d);
            depositAcc.DepositMoney(200m);
            depositAcc.WithdrawMoney(50m);
            loanAcc.CalculateInterest(20d);
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            var me = new Customer("Alex", CustomerType.Individual);
            var acc = new DepositAccount(me, 2000, 0.2);
            acc.Deposit(500);
            acc.Withdraw(600);
            Console.WriteLine("Balance: {0}", acc.Balance);
            Console.WriteLine("Interest: {0}", acc.CalculateInterest(15));
            Console.WriteLine("========");

            var loanAcc = new LoanAccount(me, 3000, 0.4);
            try
            {
                loanAcc.Withdraw(500);
            }
            catch (InvalidOperationException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 9
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();
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            try
            {
                BankAccount acc1 = new DepositAccount("Individual", 100, 1.2);
                BankAccount acc2 = new LoanAccount("Company", 2000, 2.2);
                BankAccount acc3 = new MortgageAccount("Individual", 6969, 3.3);
                BankAccount acc4 = new DepositAccount("Company", 1001, 3.3);

                BankAccount[] bankAccounts = { acc1, acc2, acc3, acc4 };

                foreach (IInterestCalculable acc in bankAccounts)
                {
                    Console.WriteLine(acc.CalculateInterest(4));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Esempio n. 11
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();
            }
        }
Esempio n. 12
0
        static void Main(string[] args)
        {
            var me  = new Customer("Alex", CustomerType.Individual);
            var acc = new DepositAccount(me, 2000, 0.2);

            acc.Deposit(500);
            acc.Withdraw(600);
            Console.WriteLine("Balance: {0}", acc.Balance);
            Console.WriteLine("Interest: {0}", acc.CalculateInterest(15));
            Console.WriteLine("========");

            var loanAcc = new LoanAccount(me, 3000, 0.4);

            try
            {
                loanAcc.Withdraw(500);
            }
            catch (InvalidOperationException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
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, 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);
            }
        }