Ejemplo n.º 1
0
        public static void TestBankAccounts()
        {
            var rnd  = new Random();
            var bank = new Bank();

            // customers to add
            var vankataCustomer = new IndividualCustomer("Ivan Ivanov");
            var vankatasCompany = new CompanyCustomer("Vankata Inc");

            // adding accounts with the above customers
            bank.AddAccount(new LoanAccount(vankataCustomer, 2010, 2.05));
            bank.AddAccount(new MortgageAccount(vankataCustomer, 2014, 10.50));
            bank.AddAccount(new DepositAccount(vankataCustomer, 15000, 7.5));
            bank.AddAccount(new LoanAccount(vankatasCompany, 50000, 6));
            bank.AddAccount(new DepositAccount(vankatasCompany, 3000, 8));
            bank.AddAccount(new MortgageAccount(vankatasCompany, 18000, 3.9));

            // foreach account added in our bank printing the total interest rate for a random selected number of month
            foreach (var account in bank.Accounts)
            {
                int months = rnd.Next(1, 15);
                Console.WriteLine(
                    "{0}'s interest rate as a(n) {1} customer for a peroid of {2} months will be {3:F2}%",
                    account.Customer.Name,
                    account.Customer.CustomerType,
                    months,
                    account.CalculateInterestAmount(months));
            }
        }
Ejemplo n.º 2
0
        public static void Main()
        {
            Customer       ivan = new IndividualCustomer("Ivan");
            DepositAccount ivanDepositAccount = new DepositAccount(ivan, 500M, 4M);

            Console.WriteLine(ivanDepositAccount.Client.Name);
            Console.WriteLine(ivanDepositAccount.InterestRate);
            ivanDepositAccount.Deposit(100M);
            Console.WriteLine(ivanDepositAccount.Balance);
            ivanDepositAccount.Withdraw(100);
            Console.WriteLine(ivanDepositAccount.Balance);
            Console.WriteLine(ivanDepositAccount.CalculateInterest(5));
            Console.WriteLine(ivanDepositAccount);

            Customer        company = new CompanyCustomer("Company");
            MortgageAccount companyMortgageAcount = new MortgageAccount(company, 100000M, 1.5M);

            Console.WriteLine(companyMortgageAcount.Client.Name);
            Console.WriteLine(companyMortgageAcount);
            companyMortgageAcount.Deposit(10000);
            Console.WriteLine(companyMortgageAcount.Balance);
            companyMortgageAcount.CalculateInterest(20);

            LoanAccount companyLoanAccount = new LoanAccount(company, 25000M, 5M);

            Console.WriteLine(companyLoanAccount);
            companyLoanAccount.Deposit(5000.50M);
            Console.WriteLine(companyLoanAccount.CalculateInterest(30));
            Console.WriteLine(companyLoanAccount);
        }
Ejemplo n.º 3
0
        public static void Main(string[] args)
        {
            Customer ivanIvanov     = new IndividualCustomer("Ivan Ivanov");
            Customer petarStoyanov  = new IndividualCustomer("Petar Stoyanov");
            Customer annaVasileva   = new IndividualCustomer("Anna Vasileva");
            Customer mariaAtanasova = new IndividualCustomer("Maria Atanasova ");
            Customer cocaCola       = new CompanyCustomer("CocaCola");
            Customer microsoft      = new CompanyCustomer("Microsoft");
            Customer apple          = new CompanyCustomer("Apple");
            Customer google         = new CompanyCustomer("Google");

            DepositAccount depositIvanIvanov    = new DepositAccount(ivanIvanov, 800m, 0.05m);
            DepositAccount depositCocaCola      = new DepositAccount(cocaCola, 5000000m, 0.02m);
            LoanAccount    loanAnnaVasilev      = new LoanAccount(annaVasileva, -10000m, 0.12m);
            LoanAccount    loanGoogle           = new LoanAccount(google, -1000000m, 0.08m);
            MortageAccount mortagePetarStoyanov = new MortageAccount(petarStoyanov, -50000m, 0.07m);
            MortageAccount mortageMictosoft     = new MortageAccount(microsoft, -5000000m, 0.06m);

            IList <Account> accounts = new List <Account>();

            accounts.Add(depositIvanIvanov);
            accounts.Add(depositCocaCola);
            accounts.Add(loanAnnaVasilev);
            accounts.Add(loanGoogle);
            accounts.Add(mortagePetarStoyanov);
            accounts.Add(mortageMictosoft);

            foreach (var account in accounts)
            {
                Console.WriteLine(account);
            }

            depositIvanIvanov.WithDraw(258.15m);
            Console.WriteLine("\nInterest for next 4 mounts:");
            foreach (var account in accounts)
            {
                Console.WriteLine("{0} {1,14:F2}", account, account.InterestAmount(4));
            }

            depositIvanIvanov.Deposit(800m);
            loanAnnaVasilev.Deposit(600.12m);
            mortagePetarStoyanov.Deposit(1825.12m);
            Console.WriteLine("\nInterest for next 8 mounts:");
            foreach (var account in accounts)
            {
                Console.WriteLine("{0} {1,14:F2}", account, account.InterestAmount(8));
            }

            Console.WriteLine("\nInterest for next 20 mounts:");
            foreach (var account in accounts)
            {
                Console.WriteLine("{0} {1,14:F2}", account, account.InterestAmount(20));
            }
        }
Ejemplo n.º 4
0
 public static void Main()
 {
     IndividualCustomer pesho = new IndividualCustomer("Pesho");
     CompanyCustomer telerik = new CompanyCustomer("Telerik");
     LoanAccount loanAcc = new LoanAccount(pesho, 250, 25);
     DepositAccount depositAcc = new DepositAccount(telerik, 10000, 20);
     loanAcc.DepositAmount(100);
     Console.WriteLine(loanAcc.Balance);
     depositAcc.WithdrawAmount(5000);
     Console.WriteLine(depositAcc.Balance);
     Console.WriteLine(depositAcc.CalculateInterestAmount(12));
 }
Ejemplo n.º 5
0
        static void Main()
        {
            IndividualCustomer inCustomerPesho = new IndividualCustomer("Pesho");
            CompanyCustomer comCustomerGoshoOOD = new CompanyCustomer("Gosho OOD");

            DepositAccount peshoDepositAcc = new DepositAccount(inCustomerPesho,500m);
            LoanAccount goshoLoanAcc = new LoanAccount(comCustomerGoshoOOD, 600m);
            MortgageAccount goshoMorAcc = new MortgageAccount(comCustomerGoshoOOD,550m);

            Console.WriteLine("\tPesho acc info");
            Console.WriteLine();

            Console.WriteLine("Balance in the begining: {0}",peshoDepositAcc.Balance);
            peshoDepositAcc.DepositAmount(6000m);
            Console.WriteLine("Balance after deposit: {0}",peshoDepositAcc.Balance);
            peshoDepositAcc.WithdrawAmount(100m);
            Console.WriteLine("Balance after withdraw: {0}",peshoDepositAcc.Balance);
            Console.WriteLine("Interest Amount: " + peshoDepositAcc.CalculateInterestAmount(50));

            Console.WriteLine();
            Console.WriteLine(new string('-',30));
            Console.WriteLine();
            Console.WriteLine("\t Gosho loan acc info");
            Console.WriteLine();

            Console.WriteLine("Balance in the begining: {0}",goshoLoanAcc.Balance);
            goshoLoanAcc.DepositAmount(50000m);
            Console.WriteLine("Balance after deposit: {0}",goshoLoanAcc.Balance);
            Console.WriteLine("Interest Amount: " + goshoLoanAcc.CalculateInterestAmount(25));
            Console.WriteLine();
            Console.WriteLine(new string('-', 30));
            Console.WriteLine();
            Console.WriteLine("\t Gosho Mortgage acc info");
            Console.WriteLine();

            Console.WriteLine("Balance in the begining: {0}",goshoMorAcc.Balance);
            goshoMorAcc.DepositAmount(50);
            Console.WriteLine("Balance after deposit: {0}",goshoMorAcc.Balance);
            Console.WriteLine("Interest Amount: " + goshoMorAcc.CalculateInterestAmount(5));
        }
Ejemplo n.º 6
0
        private static void Main()
        {
            CompanyCustomer companyBBC  = new CompanyCustomer("BBC", "UK123456", "Manchester", "0123456");
            LoanAccount     loanAccount = new LoanAccount(companyBBC, 0.5m, 10000);

            loanAccount.AddDeposit(10000);
            int months = 12;

            Console.WriteLine(
                "{0} have interest for {1} months: {2}%  ",
                loanAccount.Customer,
                months,
                loanAccount.CalculateInterestAmountForGivenTime(months));

            loanAccount.Customer = new IndividualCustomer("Stilyan Petrov", 12345, "Random", "0888 123 456");

            Console.WriteLine(
                "{0} Interest for {1} months: {2}%  ",
                loanAccount.Customer,
                months,
                loanAccount.CalculateInterestAmountForGivenTime(months));
        }