Exemple #1
0
        static void Main()
        {
            ICustomer[] clients =
            {
                new IndividualCustomer("Kiril"),
                new IndividualCustomer("Nakov"),
                new CompanyCustomer("SoftUni"),
            };

            DepositAccount  kirilDepositAccount  = new DepositAccount(clients[0], 888.354m, 55);
            MortgageAccount nakovMortgageAccount = new MortgageAccount(clients[1], 3415.77m, 12);
            LoanAccount     softUniLoanAccount   = new LoanAccount(clients[2], 56756.789m, 3);

            kirilDepositAccount.Withdraw(123.77m);
            nakovMortgageAccount.Deposit(124.55m);
            softUniLoanAccount.Deposit(1779.33m);

            // Try false input
            try
            {
                kirilDepositAccount.Withdraw(1000m);
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine(kirilDepositAccount);
            Console.WriteLine(nakovMortgageAccount);
            Console.WriteLine(softUniLoanAccount + $"\nInterest rate: {softUniLoanAccount.CalculateInterest(3)}");
        }
    private static void Main()
    {
        // Individual account test
        Costumer ivan = new Costumer("Ivan Ivanov", CostumerTypes.Individual);

        DepositAccount ivanDepositAccount = new DepositAccount(ivan, 1, 1000);

        int months = 5;

        decimal ivanInterest = ivanDepositAccount.CalculateInterest(months);

        Console.WriteLine(ivanDepositAccount.ToString() + "\n Interest for {0} months : {1}", months, ivanInterest + "\n");

        ivanDepositAccount.Withdraw(500);

        Console.WriteLine("After withdraw 500  \n" + ivanDepositAccount.ToString() + "\n");

        // Company Account test
        Costumer kokoOod = new Costumer("KOKO OOD", CostumerTypes.Company);

        LoanAccount kokoLoanAccount = new LoanAccount(kokoOod, 2, 50000);

        months = 12;

        decimal kokoInterest = kokoLoanAccount.CalculateInterest(months);
        Console.WriteLine(kokoLoanAccount.ToString() +
            "\n Interest for {0} months : {1}", months, kokoInterest + "\n");

        months = 13;
        kokoInterest = kokoLoanAccount.CalculateInterest(months);
        Console.WriteLine(kokoLoanAccount.ToString() +
            "\n Interest for {0} months : {1}", months, kokoInterest + "\n");
    }
Exemple #3
0
        // Write a program to model the bank system by classes and interfaces.
        // Identify the classes, interfaces, base classes and abstract actions
        // and implement the calculation of the interest functionality through overridden methods.
        private static void Main()
        {
            Client client1 = new ClientIndividual("Neo");
            Client client2 = new ClientCompany("Office 1");
            Client client3 = new ClientIndividual("Nakov");

            Account acc1 = new DepositAccount(client1, 5, "BG13TLRK01");
            Account acc2 = new LoanAccount(client2, 4.5m, "BG13TLRK02");
            Account acc3 = new MortgageAccount(client3, 8.8m, "BG13TLRK03");

            acc1.DepositMoney(1000);
            ((DepositAccount)acc1).WithdrawMoney(500);
            acc2.DepositMoney(10000);

            Bank bank = new Bank("New Bank");

            bank.AddAccount(acc1);
            bank.AddAccount(acc2);
            bank.AddAccount(acc3);

            Console.WriteLine(bank.Accounts);

            Console.WriteLine();
            Console.WriteLine("IBAN: {0} ({1}), Interest: {2:F2}", acc1.IBAN, acc1.Owner.Name, acc1.CalculateInterest(5));
            Console.WriteLine("IBAN: {0} ({1}), Interest: {2:F2}", acc2.IBAN, acc2.Owner.Name, acc2.CalculateInterest(6));
            Console.WriteLine("IBAN: {0} ({1}), Interest: {2:F2}", acc3.IBAN, acc3.Owner.Name, acc3.CalculateInterest(18));

            Console.WriteLine("\nRemoving account 1");
            bank.RemoveAccount(acc1);
            Console.WriteLine(bank.Accounts);
        }
        static void Main()
        {
            Customers kris = new Individuals("Kris", "65654756765", "Sofia", new DateTime(1990, 10, 25));

            Customers krisOOD = new Companies("Kris OOD", "65654656765", "Plovdiv", 325343);

            Console.WriteLine(krisOOD is Individuals);
            Console.WriteLine(kris is Individuals);

            Bank mortgageAccTest = new MortgageAccount(200.2m, 0.6m, kris);
            Bank mortgageAccTest1 = new MortgageAccount(200.2m, 0.6m, krisOOD);

            Console.WriteLine(mortgageAccTest.CalculateInterest(15));
            Console.WriteLine(mortgageAccTest1.CalculateInterest(15));

            Bank loanAccTest = new LoanAccount(200.2m, 0.6m, kris);
            Bank loanAccTest1 = new LoanAccount(200.2m, 0.6m, krisOOD);

            Console.WriteLine(loanAccTest.CalculateInterest(11));
            Console.WriteLine(loanAccTest1.CalculateInterest(11));

            Bank depositAccTest = new DepositAccount(3200.2m, 0.6m, kris);
            Bank depositAccTest1 = new DepositAccount(1200.2m, 0.6m, krisOOD);

            Console.WriteLine(depositAccTest.CalculateInterest(11));
            Console.WriteLine(depositAccTest1.CalculateInterest(11));

            depositAccTest.Deposit(200);
            Console.WriteLine(depositAccTest.Balance);
            var depositAcc = depositAccTest as DepositAccount;
            depositAcc.Draw(300);
            Console.WriteLine(depositAcc.Balance);
        }
Exemple #5
0
        public int statuschange(string aid, string status)
        {
            if (status == "Accepted")
            {
                double p = db.CustomerApplications.Find(aid).LoanAmount;

                int         n  = db.CustomerApplications.Find(aid).Tenure;
                LoanAccount la = new LoanAccount();
                la.AppID           = aid;
                la.Balance         = p;
                la.PrincipleAmount = p;
                la.EMIStartDate    = DateTime.Today;
                la.EMIEndDate      = DateTime.Today.AddMonths(n);
                la.EMINextDate     = DateTime.Today.AddMonths(1);
                la.EMI_Installment = p * 8.5 * (Math.Pow(9.5, n)) / ((Math.Pow(9.5, n)) - 1);
                la.TenureRemaining = n - 1;
                db.LoanAccounts.Add(la);
                try
                {
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    {
                        throw e;
                    }
                }
            }
            return(db.proc_changeStatus(aid, status));
        }
    static void Main()
    {
        Bank bank = new Bank();

        DepositAccount depAccC = new DepositAccount(new Company(), 300M, 0.4M);
        DepositAccount depAccI = new DepositAccount(new Individual(), 1000M, 0.4M);

        LoanAccount loanAccC = new LoanAccount(new Company(), 1000M, 0.4M);
        LoanAccount loanAccI = new LoanAccount(new Individual(), 1000M, 0.4M);

        MortgageAccount mortAccC = new MortgageAccount(new Company(), 1000M, 0.4M);
        MortgageAccount mortAccI = new MortgageAccount(new Individual(), 1000M, 0.4M);

        bank.AddAccount(depAccC);
        bank.AddAccount(depAccI);
        bank.AddAccount(loanAccC);
        bank.AddAccount(loanAccI);
        bank.AddAccount(mortAccC);
        bank.AddAccount(mortAccI);

        foreach (var acc in bank.Accounts)
        {
            Console.WriteLine(acc.CalculateInterestAmount(12));
        }
    }
        public decimal ComputeNewLoanBalance(LoanAccount loanAccount, decimal newInterestRate, string type, string interestRateDescription)
        {
            decimal newLoanBalance = 0;
            var loanAmount = loanAccount.LoanAmount;
            var agreementItem = loanAccount.FinancialAccount.Agreement.AgreementItems.FirstOrDefault(entity => entity.IsActive == true);

            newLoanBalance = loanAmount;
            var payments = loanAccount.FinancialAccount.FinAcctTrans.Where(entity => entity.FinancialAcctTransTypeId == FinlAcctTransType.AccountPaymentType.Id).ToList();

            if (payments.Count() != 0)
            {
                foreach (var pay in payments)
                {
                    var balance = 0M;
                    if (type == ProductFeature.DiminishingBalanceMethodType.Name)
                        balance = ComputeInterestAmount(newLoanBalance, newInterestRate, interestRateDescription); //11/09/11
                        //balance = ComputeInterestAmount(newLoanBalance, newInterestRate, interestRateDescription, pay.TransactionDate, agreementItem, loanAccount, DateTime.Now);
                    else
                        balance = ComputeInterestAmount(loanAmount, newInterestRate, interestRateDescription);
                        //balance = ComputeInterestAmount(loanAmount, newInterestRate, interestRateDescription, pay.TransactionDate, agreementItem, loanAccount, DateTime.Now);
                    newLoanBalance = (newLoanBalance + balance);
                    var amountPaid = pay.Amount;
                    newLoanBalance -= amountPaid;
                }
            }
            return newLoanBalance;
        }
Exemple #8
0
 public ActionResult Pay(string accountID, string Debit, string paymentvalue)
 {
     try
     {
         double      balance = double.Parse(Debit) - double.Parse(paymentvalue);
         int         accid   = int.Parse(accountID);
         LoanAccount la      = _db.LoanAccounts.Find(accid) as LoanAccount;
         la.Debit = balance;
         Transaction ta = new Transaction()
         {
             id                 = 0,
             accountID          = int.Parse(accountID),
             transactionMessage = "Deposit of " + paymentvalue
         };
         _db.Transactions.Add(ta);
         _db.Entry(la).State = EntityState.Modified;
         _db.SaveChanges();
         ViewBag.Confirm = $"Your payment of {paymentvalue} was completed for account {accountID}";
         return(View("Confirmed"));
     }
     catch
     {
         return(RedirectToAction("Index"));
     }
 }
Exemple #9
0
        public async Task <IActionResult> Edit(int id, [Bind("MonthlyDue,Id,OwnerId,type,Amount")] LoanAccount loanAccount)
        {
            if (id != loanAccount.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(loanAccount);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LoanAccountExists(loanAccount.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(loanAccount));
        }
        public decimal ComputeNewLoanBalance(LoanAccount loanAccount, decimal receivableAdd, decimal newInterestRate, string type, string interestRateDescription)
        {
            var agreementItem = new AgreementItem();

            decimal newLoanBalance = 0;
            var loanAmount = loanAccount.LoanAmount;
            loanAmount += receivableAdd;

            newLoanBalance = loanAmount;
            var payments = loanAccount.FinancialAccount.FinAcctTrans.Where(entity => entity.FinancialAcctTransTypeId == FinlAcctTransType.AccountPaymentType.Id).ToList();
            var groupedPayments = from p in payments
                                  group p by p.TransactionDate.Month into g
                                  select new { Amount = g.Sum(entity => entity.Amount) };
            if (payments.Count() != 0)
            {
                foreach (var pay in payments)
                {
                    var balance = 0M;
                    if (type == ProductFeature.DiminishingBalanceMethodType.Name)
                        balance = ComputeInterestAmount(newLoanBalance, newInterestRate, interestRateDescription);
                    else
                        balance = ComputeInterestAmount(loanAmount, newInterestRate, interestRateDescription);
                    newLoanBalance = (newLoanBalance + balance);
                    var amountPaid = pay.Amount;
                    newLoanBalance -= amountPaid;
                }
            }
            return newLoanBalance;
        }
Exemple #11
0
        public static void Main()
        {
            ICustomer[] clients =
            {
                new IndividualCustomer("Pesho"),
                new IndividualCustomer("Gosho"),
                new CompanyCustomer("Soft Uni LTD"),
                new CompanyCustomer("Manchester United FC"),
            };

            var depositAcc = new DepositAccount(clients[0], 8955.33m, 0.005);
            var loanAcc = new LoanAccount(clients[1], 500m, 0.002);
            var mortgageAcc = new MortgageAccount(clients[2], 5m, 0.009);
            var depositAcc2 = new DepositAccount(clients[3], 159, 0.08);

            depositAcc.Withdraw(6000m);
            depositAcc2.Withdraw(54.22m);
            mortgageAcc.Deposit(15m);
            loanAcc.Deposit(5559.66m);

            try
            {
                depositAcc.Withdraw(500000000m);
            }
            catch (ArgumentException ex)
            {
                Console.Error.WriteLine(ex.Message);
            }

            Console.WriteLine(depositAcc2);
            Console.WriteLine(mortgageAcc);

            Console.WriteLine(loanAcc + $" Interest rate: {loanAcc.CalculateIntereset(12):C}");
        }
        public static void Main()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            DepositAccount dep = new DepositAccount(cust: Customer.Company, balance: 200, interestRate: 20);

            Console.WriteLine("Deposit account's Interest Amount: {0}", dep.GetInterestAmount(months: 6));

            // when balance is more than 1000
            dep.Deposit(900m);
            Console.WriteLine("Deposit account's Interest Amount: {0}\n", dep.GetInterestAmount(months: 6));

            // individual
            LoanAccount loanIndividual = new LoanAccount(cust: Customer.Individual, balance: 100, interestRate: 15);

            Console.WriteLine("Loan individual account's Interest Amount: {0}", loanIndividual.GetInterestAmount(months: 3));
            Console.WriteLine("Loan individual account's Interest Amount: {0}\n", loanIndividual.GetInterestAmount(months: 5));

            // company
            LoanAccount loanCompany = new LoanAccount(cust: Customer.Company, balance: 100, interestRate: 15);

            Console.WriteLine("Loan company account's Interest Amount: {0}", loanCompany.GetInterestAmount(months: 2));
            Console.WriteLine("Loan company account's Interest Amount: {0}\n", loanCompany.GetInterestAmount(months: 5));

            // individual
            MortgageAccount mortIndividual = new MortgageAccount(cust: Customer.Individual, balance: 350, interestRate: 5);

            Console.WriteLine("Mortgage individual account's Interest Amount: {0}", mortIndividual.GetInterestAmount(months: 7));
            Console.WriteLine("Mortgage individual account's Interest Amount: {0}\n", mortIndividual.GetInterestAmount(months: 8));

            // company
            MortgageAccount mortCompany = new MortgageAccount(cust: Customer.Company, balance: 20000, interestRate: 10);

            Console.WriteLine("Mortgage company account's Interest Amount: {0}", mortCompany.GetInterestAmount(months: 10));
            Console.WriteLine("Mortgage company account's Interest Amount: {0}\n", mortCompany.GetInterestAmount(months: 24));
        }
Exemple #13
0
    static void Main()
    {
        Bank bank = new Bank();

        DepositAccount depAccC = new DepositAccount(new Company(), 300M, 0.4M);
        DepositAccount depAccI = new DepositAccount(new Individual(), 1000M, 0.4M);

        LoanAccount loanAccC = new LoanAccount(new Company(), 1000M, 0.4M);
        LoanAccount loanAccI = new LoanAccount(new Individual(), 1000M, 0.4M);

        MortgageAccount mortAccC = new MortgageAccount(new Company(), 1000M, 0.4M);
        MortgageAccount mortAccI = new MortgageAccount(new Individual(), 1000M, 0.4M);

        bank.AddAccount(depAccC);
        bank.AddAccount(depAccI);
        bank.AddAccount(loanAccC);
        bank.AddAccount(loanAccI);
        bank.AddAccount(mortAccC);
        bank.AddAccount(mortAccI);

        foreach (var acc in bank.Accounts)
        {
            Console.WriteLine(acc.CalculateInterestAmount(12));
        }
    }
        private static void CreateAccount(Customer customer)
        {
            string accountType;
            double startingBalance;
            string accountNumber = "ABC0000";

            do
            {
                Console.Write("Enter Account Type(Mortgage/Loan/Deposit): ");
                accountType = Console.ReadLine();
            }while (!String.Equals(accountType, "Mortgage") && !String.Equals(accountType, "Loan") && !String.Equals(accountType, "Deposit"));

            Console.Write("Enter Starting Balance: ");
            startingBalance = Convert.ToDouble(Console.ReadLine());
            accountNumber   = accountNumber + _rand.Next(5, 10);
            if (String.Equals(accountType, "Mortgage"))
            {
                var mortgageAccount = new MortgageAccount(customer, startingBalance, accountNumber);
                _accounts.Add(mortgageAccount);
            }
            else if (String.Equals(accountType, "Loan"))
            {
                var loanAccount = new LoanAccount(customer, startingBalance, accountNumber);
                _accounts.Add(loanAccount);
            }
            else
            {
                var depoAccount = new DepositAccount(customer, startingBalance, accountNumber);
                _accounts.Add(depoAccount);
            }
        }
        //StandingCheckAndSet
        public void StandingCheckAndSet(User user)
        {
            bool goodStanding = true;

            foreach (IAccount acc in user.Accounts)
            {
                if (acc is BusinessAccount)
                {
                    BusinessAccount biz = (BusinessAccount)acc;
                    if (biz.CurrentBalance < 0)
                    {
                        ((BusinessAccount)acc).IsOverdraft     = true;
                        ((BusinessAccount)acc).OverDraftAmount = ((BusinessAccount)acc).CurrentBalance;
                        goodStanding = false;
                    }
                }
                if (acc is LoanAccount)
                {
                    LoanAccount loan = (LoanAccount)acc;
                    if (Math.Abs(loan.CurrentBalance - loan.MaximumBalance) < double.Epsilon)
                    {
                        goodStanding = false;
                    }
                }
            }
            user.GoodStanding = goodStanding;
            UserDAL userDAL = new UserDAL();

            userDAL.UpdateUserDAL(user);
        }
        static void Main()
        {
            ICustomer[] clients =
            {
                new IndividualCustomer("Kiril"),
                new IndividualCustomer("Nakov"),
                new CompanyCustomer("SoftUni"),
            };

            DepositAccount kirilDepositAccount = new DepositAccount(clients[0],888.354m,55);
            MortgageAccount nakovMortgageAccount = new MortgageAccount(clients[1],3415.77m,12);
            LoanAccount softUniLoanAccount = new LoanAccount(clients[2],56756.789m,3);

            kirilDepositAccount.Withdraw(123.77m);
            nakovMortgageAccount.Deposit(124.55m);
            softUniLoanAccount.Deposit(1779.33m);

            // Try false input
            try
            {
                kirilDepositAccount.Withdraw(1000m);
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine(kirilDepositAccount);
            Console.WriteLine(nakovMortgageAccount);
            Console.WriteLine(softUniLoanAccount + $"\nInterest rate: {softUniLoanAccount.CalculateInterest(3)}");

        }
Exemple #17
0
    static void Main()
    {
        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

        DepositAccount depAccountInd = new DepositAccount(new Individual("Boyko Draganov", "9090909090"), 230m, 0.003m);
        DepositAccount depAccountComp = new DepositAccount(new Company("Barista", "999999999"), 13000m, 0.006m);

        MortgageAccount mortAccountInd = new MortgageAccount(new Individual("Georgi Dimitrov", "9090909190"), 2300m, 0.005m);
        MortgageAccount mortAccountComp = new MortgageAccount(new Company("Sky", "999999999"), 35000m, 0.008m);

        LoanAccount loanAccountInd = new LoanAccount(new Individual("Hani Kovachev", "9090909190"), 2300m, 0.005m);
        LoanAccount loanAccountComp = new LoanAccount(new Company("Scraper BG", "999999999"), 5000m, 0.002m);

        List<Account> accounts = new List<Account>(){depAccountInd, depAccountComp, mortAccountInd, mortAccountComp,
        loanAccountInd, loanAccountComp};

        foreach (var acc in accounts)
        {
            Console.WriteLine("I am {0}, I am owned by {1}, my current balance is \n{2} and the interest rate for {3} months is: {4:F2}", acc.GetType(),
                acc.Customer.GetType(), acc.Balance, 3, acc.CalculateInterest(3));
            Console.WriteLine(new string('-', 50));
        }
        depAccountInd.DepositMoney(1000);
        depAccountInd.WithdrawMoney(130);

        Console.WriteLine("Deposit Account owned by Individual:\nMy current balance is:{0}, and my interest for 2 months is: {1:F2}",
        depAccountInd.Balance, depAccountInd.CalculateInterest(2));
    }
Exemple #18
0
        public static void Main()
        {
            Bank bank = new Bank();

            Customer pesho  = new Customer("Pesho", CustomerType.Individual);
            Customer milko  = new Customer("Milko", CustomerType.Individual);
            Customer jichka = new Customer("jichka", CustomerType.Individual);

            Customer dell  = new Customer("Dell", CustomerType.Company);
            Customer hp    = new Customer("HP", CustomerType.Company);
            Customer apple = new Customer("Apple", CustomerType.Company);

            DepositAccount  peshoAccount  = new DepositAccount(pesho, 4300, 2.2m);
            LoanAccount     milkoAccount  = new LoanAccount(milko, 9999, 3.7m);
            MortgageAccount jichkaAccount = new MortgageAccount(jichka, 559, 1.2m);

            Account dellAccount  = new DepositAccount(dell, 17631782.4234m, 7.1m);
            Account hpAccount    = new LoanAccount(hp, 111111.1114m, 4.4m);
            Account appleAccount = new MortgageAccount(apple, 1888631782.4934234m, 11.1m);

            peshoAccount.Deposit(400.50m);
            peshoAccount.Withdraw(200);

            bank.AddAccount(peshoAccount);
            bank.AddAccount(milkoAccount);
            bank.AddAccount(jichkaAccount);
            bank.AddAccount(dellAccount);
            bank.AddAccount(hpAccount);
            bank.AddAccount(appleAccount);

            foreach (IAccount account in bank.Accounts)
            {
                Console.WriteLine($"{account} -- with interest for 23 months -> {account.CalculateInterest(23):F1}\n");
            }
        }
Exemple #19
0
        public static void Main()
        {
            ICustomer[] clients =
            {
                new IndividualCustomer("Dimitar Dimitrov"),
                new IndividualCustomer("Petar Ivanov"),
                new CompanyCustomer("Glavbulgarstroy OOD"),
                new CompanyCustomer("Monbat AD"),
            };

            var depositAccount = new DepositAccount(clients[0], 18000m, 0.004);
            var loanAccount = new LoanAccount(clients[1], 500m, 0.015);
            var mortgageAccount = new MortgageAccount(clients[0], 5000m, 0.009);
            var depositAccount2 = new DepositAccount(clients[2], 100000m, 0.010);
            var depositAccount3 = new DepositAccount(clients[3], 1200, 0.08);

            depositAccount.Withdraw(1000m);
            depositAccount2.Withdraw(500m);
            mortgageAccount.Deposit(15m);
            loanAccount.Deposit(100m);

            try
            {
                depositAccount.Withdraw(100000m);
            }
            catch (ArgumentException ex)
            {
                Console.Error.WriteLine(ex.Message);
            }

            Console.WriteLine(depositAccount2);
            Console.WriteLine(mortgageAccount);

            Console.WriteLine(loanAccount + string.Format(" Interest : {0:C}", loanAccount.CalculateInterest(12)));
        }
        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));
        }
Exemple #21
0
        public Dictionary <String, String> GetCustomerAccounts(int custID)
        {
            Dictionary <String, String> accountLists = new Dictionary <string, string>();
            List <Account> custAccList = GetAllCustomerAccounts(custID);

            Console.Clear();
            //Console.WriteLine("The following are your available accounts");

            foreach (Account acc in custAccList)
            {
                if (acc is PersonalCheckingAccount)
                {
                    PersonalCheckingAccount acc2 = acc as PersonalCheckingAccount;
                    accountLists.Add($"Type: Personal Checking  Credit: {acc2.Credit}  Debit: {acc2.Debit}  ID: {acc.AccountID}", "PersonalCheckingAccount");
                }
                else if (acc is BusinessCheckingAccount)
                {
                    BusinessCheckingAccount acc2 = acc as BusinessCheckingAccount;
                    accountLists.Add($"Type: Business Checking  Credit: {acc2.Credit}  Debit: {acc2.Debit}  ID: {acc.AccountID}", "BusinessCheckingAccount");
                }
                else if (acc is LoanAccount)
                {
                    LoanAccount acc2 = acc as LoanAccount;
                    accountLists.Add($"Type: Loan  Debit: {acc2.Debit}  Interest Rate: {acc2.interestRate} ID: {acc.AccountID}", "LoanAccount");
                }
                else if (acc is TermDepositAccount)
                {
                    TermDepositAccount acc2 = acc as TermDepositAccount;
                    accountLists.Add($"Type: Term Deposit  Credit: {acc2.Credit}  Term Length: {acc2.depositTerm} Interest Rate: {acc2.interestRate} ID: {acc.AccountID}", "TermDepositAccount");
                }
            }

            return(accountLists);
        }
Exemple #22
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));
        }
Exemple #23
0
        internal static void CreateAccount(Bank mybank)
        {
            Console.WriteLine("\nSelect Account type:\n1. Loan Account,  2.Deposit Account");
            Console.Write("Your Reply: ");
            string    option = Console.ReadLine();
            ICustomer newCustomer; decimal startAmt;

            switch (Convert.ToInt32(option))
            {
            case 1:
                Console.Write("Enter Amount: ");
                startAmt = Utility.GetDecimal(Console.ReadLine());
                Console.WriteLine("Enter Loan Duration (greater than 3): ");
                int duration = Convert.ToInt32(Console.ReadLine());
                newCustomer = GenerateNewCustomer(GetCustomerType());
                LoanAccount acct = new LoanAccount(newCustomer, startAmt, duration);
                mybank.AddNewAccount(acct);
                break;

            case 2:
                Console.Write("Enter Amount: ");
                startAmt = Utility.GetDecimal(Console.ReadLine());
                Console.Write("Choose your Deposit Account Type\n Reply with Student,Savings or Current:  ");
                DepositAccountType acctType = Utility.GetDepositAccountType(Console.ReadLine());
                newCustomer = GenerateNewCustomer(GetCustomerType());
                DepositAccount acctDep = new DepositAccount(newCustomer, acctType, startBalance: startAmt);
                mybank.AddNewAccount(acctDep);
                break;

            default:
                throw new ArgumentException("Invalid Account type entered.");
            }
        }
Exemple #24
0
        static void Main(string[] args)
        {
            var savingsAccount = new SavingsAccount(owner: "Joe Decker",
                                                    balance: 200);

            savingsAccount.ShowAccountDetails();
            savingsAccount.Withdraw(20);
            savingsAccount.CheckRemainingBalance();
            savingsAccount.Deposit(100);
            savingsAccount.CheckRemainingBalance();

            var loanAccount = new LoanAccount(owner: "John Wright",
                                              balance: -1200);

            loanAccount.ShowAccountDetails();
            loanAccount.Deposit(200);
            loanAccount.CheckRemainingBalance();

            var investmentAccount = new InvestmentAccount(owner: "Mike Schwartz",
                                                          balance: 10000);

            investmentAccount.ShowAccountDetails();
            investmentAccount.Withdraw(2000);
            investmentAccount.CheckRemainingBalance();
            investmentAccount.Deposit(1200);
            investmentAccount.CheckRemainingBalance();
        }
    static void Main()
    {
        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

        DepositAccount depAccountInd  = new DepositAccount(new Individual("Boyko Draganov", "9090909090"), 230m, 0.003m);
        DepositAccount depAccountComp = new DepositAccount(new Company("Barista", "999999999"), 13000m, 0.006m);

        MortgageAccount mortAccountInd  = new MortgageAccount(new Individual("Georgi Dimitrov", "9090909190"), 2300m, 0.005m);
        MortgageAccount mortAccountComp = new MortgageAccount(new Company("Sky", "999999999"), 35000m, 0.008m);

        LoanAccount loanAccountInd  = new LoanAccount(new Individual("Hani Kovachev", "9090909190"), 2300m, 0.005m);
        LoanAccount loanAccountComp = new LoanAccount(new Company("Scraper BG", "999999999"), 5000m, 0.002m);

        List <Account> accounts = new List <Account>()
        {
            depAccountInd, depAccountComp, mortAccountInd, mortAccountComp,
            loanAccountInd, loanAccountComp
        };


        foreach (var acc in accounts)
        {
            Console.WriteLine("I am {0}, I am owned by {1}, my current balance is \n{2} and the interest rate for {3} months is: {4:F2}", acc.GetType(),
                              acc.Customer.GetType(), acc.Balance, 3, acc.CalculateInterest(3));
            Console.WriteLine(new string('-', 50));
        }
        depAccountInd.DepositMoney(1000);
        depAccountInd.WithdrawMoney(130);

        Console.WriteLine("Deposit Account owned by Individual:\nMy current balance is:{0}, and my interest for 2 months is: {1:F2}",
                          depAccountInd.Balance, depAccountInd.CalculateInterest(2));
    }
Exemple #26
0
        //Get All accounts
        private IEnumerable <LoanAccount> GetLoanAccounts()
        {
            try
            {
                using (var command = new SqlCommand())
                {
                    var accounts = new List <LoanAccount>();

                    command.CommandText = "usp_GetAll_LoanOutStandingBalance";

                    var dt = GetData(command);

                    if (dt != null && dt.Rows.Count > 0)
                    {
                        foreach (DataRow r in dt.Rows)
                        {
                            var account = new LoanAccount
                            {
                                Account_Number = r["Account_Number"].ToString(),
                                Account_Name   = r["Account_Name"].ToString(),
                                Balance        = Convert.ToDecimal(r["Balance"])
                            };
                            accounts.Add(account);
                        }
                    }
                    return(accounts);
                }
            }
            catch (Exception ex)
            {
                _errorMessage = ex.Message;
            }
            return(null);
        }
Exemple #27
0
        static void Main()
        {
            IAccount       depositIndividualAccount = new DepositAccount(Customer.Individual, 120.00m, 21.00m);
            DepositAccount depositCompany           = new DepositAccount(Customer.Company, 240.00m, 25.00m);
            IAccount       loanIndividial           = new LoanAccount(Customer.Individual, 20.00m, 15.00m);
            IAccount       loanCompany        = new LoanAccount(Customer.Company, 200.00m, 17.00m);
            IAccount       mortgageIndividial = new MortgageAccount(Customer.Individual, 2000.00m, 5.00m);
            IAccount       mortgageCompany    = new MortgageAccount(Customer.Company, 5000.00m, 7.00m);

            Console.WriteLine("Deposit individial account CalculateInterestAmountForPeriod for 5 month is ${0}",
                              depositIndividualAccount.CalculateInterestAmountForPeriod(5));
            Console.WriteLine("Deposit individial account Balance before deposit is ${0}", depositIndividualAccount.Balance);
            depositIndividualAccount.Deposit(50);
            Console.WriteLine("Deposit individial account Balance after deposit is ${0}", depositIndividualAccount.Balance);
            Console.WriteLine("Deposit company account CalculateInterestAmountForPeriod for 2 month is ${0}",
                              depositCompany.CalculateInterestAmountForPeriod(2));
            Console.WriteLine("Deposit company account Balance before draw money is ${0}", depositCompany.Balance);
            depositCompany.DrawMoney(2000);
            Console.WriteLine("Deposit company account Balance after draw money is ${0}", depositCompany.Balance);
            Console.WriteLine("Loan individial account CalculateInterestAmountForPeriod for 2 month is ${0}",
                              loanIndividial.CalculateInterestAmountForPeriod(2));
            Console.WriteLine("Loan company account CalculateInterestAmountForPeriod for 1 month is ${0}",
                              loanCompany.CalculateInterestAmountForPeriod(1));
            Console.WriteLine("Mortgage individial account CalculateInterestAmountForPeriod for 6 month is ${0}",
                              mortgageIndividial.CalculateInterestAmountForPeriod(6));
            Console.WriteLine("Mortgage company account CalculateInterestAmountForPeriod for 7 month is ${0}",
                              mortgageCompany.CalculateInterestAmountForPeriod(7));
        }
        public async Task <LoanAccount> AddLoanAccountAsync(LoanAccountViewModel accountViewModel)
        {
            var customer = await _context.Customers.Include(c => c.Accounts).FirstOrDefaultAsync(c => c.CustomerId == accountViewModel.LinkedAccount.CustomerId);

            var settings = _context.AccountConfigurations.First();

            if (customer.Accounts.Any(a => a.AccountClass == AccountClass.Loan))
            {
                throw new Exception($"Unable to create account. Customer already has a Loan account in the system.");
            }
            var loanAccount = new LoanAccount()
            {
                CustomerAccount          = accountViewModel.LinkedAccount,
                IsActivated              = true,
                AccountClass             = AccountClass.Loan,
                AccountName              = $"{customer.FirstName} {customer.LastName} Loan",
                DateOpened               = DateTime.Now,
                Principal                = accountViewModel.Principal,
                InterestRate             = (double)settings.LoanInterestRate,
                DurationYears            = accountViewModel.DurationYears,
                RepaymentFrequencyMonths = accountViewModel.RepaymentFrequencyMonths,
                StartDate                = accountViewModel.StartDate,
                Customer = accountViewModel.LinkedAccount.Customer
            };

            _context.Add(loanAccount);
            var noPaymentsPerYear = 12 / loanAccount.RepaymentFrequencyMonths;

            loanAccount.CompoundInterest = (loanAccount.Principal * Math.Pow((1 + (loanAccount.InterestRate / 100) / (noPaymentsPerYear)), (noPaymentsPerYear * loanAccount.DurationYears))) - loanAccount.Principal;
            loanAccount.AccountNumber    = GenerateCustomerAccountNumber(loanAccount.AccountClass, loanAccount.CustomerId, loanAccount.GLAccountId);
            await _context.SaveChangesAsync();


            return(loanAccount);
        }
Exemple #29
0
        static void Main(string[] args)
        {
            Individual kiro = new Individual("Kiro");
            Individual ivan = new Individual("Ivan");
            Company    sap  = new Company("SAP");

            DepositAccount  kiroAccount = new DepositAccount(kiro, 1112, 0.2m);
            LoanAccount     ivanAccount = new LoanAccount(ivan, 2222, 0.29m);
            MortgageAccount sapAccount  = new MortgageAccount(sap, 3333, 0.23m);

            List <Account> accounts = new List <Account>()
            {
                kiroAccount,
                ivanAccount,
                sapAccount
            };

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

            Console.WriteLine(kiroAccount.CalculateInterestrate(4));
            Console.WriteLine(sapAccount.CalculateInterestrate(55));
            sapAccount.Deposit(4141);
            kiroAccount.Withdraw(333);

            foreach (var account in accounts)
            {
                Console.WriteLine(account);
            }
        }
Exemple #30
0
        //Get Loan Account Outstanding by Account number
        public LoanAccount GetLoanOutstandingBalance(string account_number)
        {
            try
            {
                using (var command = new SqlCommand())
                {
                    command.CommandText = "usp_Get_LoanOutStandingBalance";
                    command.Parameters.AddWithValue("@accountnumber", account_number);

                    var dt = GetData(command);

                    if (dt != null && dt.Rows.Count > 0)
                    {
                        var r = dt.Rows[0];

                        var account = new LoanAccount
                        {
                            Account_Number = r["Account_Number"].ToString(),
                            Account_Name   = r["Account_Name"].ToString(),
                            Balance        = Convert.ToDecimal(r["Balance"])
                        };
                        return(account);
                    }
                }
            }
            catch (Exception ex)
            {
                _errorMessage = ex.Message;
            }
            return(null);
        }
Exemple #31
0
        public static void Main()
        {
            ICustomer[] clients =
            {
                new IndividualCustomer("Pesho"),
                new IndividualCustomer("Gosho"),
                new CompanyCustomer("Soft Uni LTD"),
                new CompanyCustomer("Soft Uni Student Organisation"),
            };

            var depositAcc  = new DepositAccount(clients[0], 8955.33m, 0.005);
            var loanAcc     = new LoanAccount(clients[1], 1200m, 0.002);
            var mortgageAcc = new MortgageAccount(clients[2], 7005m, 0.009);
            var depositAcc2 = new DepositAccount(clients[3], 159, 0.08);

            depositAcc.Withdraw(6000m);
            depositAcc2.Withdraw(54.22m);
            mortgageAcc.Deposit(15m);
            loanAcc.Deposit(5559.66m);

            try
            {
                depositAcc.Withdraw(500000000m);
            }
            catch (ArgumentException ex)
            {
                Console.Error.WriteLine(ex.Message);
            }

            Console.WriteLine(depositAcc2);
            Console.WriteLine(mortgageAcc);

            Console.WriteLine(loanAcc + $" Interest rate: {loanAcc.CalculateIntereset(12):C}");
        }
Exemple #32
0
    static void Main()
    {
        Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

        Customer depositAccountCustomer = new IndividualCustomer(
            "2343PJ34752",
            "William",
            "Harris",
            "1 Microsoft Way, Redmond, WA",
            "1-888-553-6562");

        DepositAccount depositAccount = new DepositAccount(
            depositAccountCustomer,
            2500,
            1.0825M,
            12);

        Customer loanAccountCustomer = new CorporateCustomer(
            "89BPQ123YJ0",
            "Oracle Corporation",
            "500 Oracle Parkway, Redwood Shores, Redwood City, California, United States",
            "1-981-717-9366");

        Account loanAccount = new LoanAccount(
            loanAccountCustomer,
            1000000000,
            1.0931M,
            24);

        Customer mortgageLoanAccountCustomer = new IndividualCustomer(
            "97A20LX3YJU",
            "Ginni",
            "Rometty",
            "Armonk, New York, U.S.",
            "1-129-342-3817");

        Account mortgageLoanAccount = new MortgageLoanAccount(
            mortgageLoanAccountCustomer,
            300000,
            1.0875M,
            36);

        decimal depositInterest = depositAccount.CalculateInterest(3);

        Console.WriteLine("Deposit account interest: {0:C2}", depositInterest);

        depositAccount.Deposit(459.76M);
        depositAccount.Withdraw(400.76M);

        Console.WriteLine("Deposit account balance: {0:C2}", depositAccount.Balance);

        decimal loanInterest = loanAccount.CalculateInterest(10);

        Console.WriteLine("Loan account interest: {0:C2}", loanInterest);

        decimal mortgageLoanInterest = mortgageLoanAccount.CalculateInterest(10);

        Console.WriteLine("Mortgage loan account interest: {0:C2}", mortgageLoanInterest);
    }
        static void Main()
        {
            // Making instances of all types of accounts with the two types of customers
            DepositAccount first = new DepositAccount(new IndividualCustomer("Jimmy Hendrix"), 1500, 5);
            DepositAccount second = new DepositAccount(new CompanyCustomer("Jimmy Hendrix"), 500, 5);
            LoanAccount third = new LoanAccount(new IndividualCustomer("Jimmy Hendrix"), 4000, 7);
            LoanAccount fourth = new LoanAccount(new CompanyCustomer("Jimmy Hendrix"), 50000, 3);
            MortgageAccount fifth = new MortgageAccount(new IndividualCustomer("Jimmy Hendrix"), 34000, 4);
            MortgageAccount sixth = new MortgageAccount(new CompanyCustomer("Jimmy Hendrix"), 19000, 9);
            // Testing the DepositMoney, WithDrawMoney and CalculateInterest methods for all account types
            Console.WriteLine("INDIVIDUAL DEPOSIT ACCOUNT:");
            Console.WriteLine("Balance: {0}", first.Balance);
            first.DepositMoney(10);
            Console.WriteLine("Balance after deposit: {0}", first.Balance);
            first.WithDrawMoney(150);
            Console.WriteLine("Balance after withdraw: {0}", first.Balance);
            Console.WriteLine("Calculate interest: {0}", first.CalculateInterest(5));
            Console.WriteLine();
            Console.WriteLine("CUSTOMER DEPOSIT ACCOUNT: ");
            Console.WriteLine("Balance: {0}", second.Balance);
            second.DepositMoney(2000);
            Console.WriteLine("Balance after deposit: {0}", second.Balance);
            second.WithDrawMoney(1800);
            Console.WriteLine("Balance after withdraw: {0}", second.Balance);
            Console.WriteLine("Calculate interest: {0}", second.CalculateInterest(9));
            Console.WriteLine();
            Console.WriteLine("INDIVIDUAL LOAN ACCOUNT:");
            Console.WriteLine("Balance: {0}", third.Balance);
            third.DepositMoney(60);
            Console.WriteLine("Balance after deposit: {0}", third.Balance);
            Console.WriteLine("Calculate interest: {0}", third.CalculateInterest(7));
            Console.WriteLine();
            Console.WriteLine("CUSTOMER LOAN ACCOUNT:");
            Console.WriteLine("Balance: {0}", fourth.Balance);
            fourth.DepositMoney(60);
            Console.WriteLine("Balance after deposit: {0}", fourth.Balance);
            Console.WriteLine("Calculate interest: {0}", fourth.CalculateInterest(9));
            Console.WriteLine();
            Console.WriteLine("INDIVIDUAL MORTGAGE ACCOUNT:");
            Console.WriteLine("Balance: {0}", fifth.Balance);
            fifth.DepositMoney(100);
            Console.WriteLine("Balance after deposit: {0}", fifth.Balance);
            Console.WriteLine("Calculate interest: {0}", fifth.CalculateInterest(6));
            Console.WriteLine();
            Console.WriteLine("CUSTOMER MORTGAGE ACCOUNT:");
            Console.WriteLine("Balance: {0}", sixth.Balance);
            sixth.DepositMoney(100);
            Console.WriteLine("Balance after deposit: {0}", sixth.Balance);
            Console.WriteLine("Calculate interest: {0}", sixth.CalculateInterest(11));

            // Testing the Bank class and the AddAccount method
            Bank newBank = new Bank(LoadList());
            Console.WriteLine();
            newBank.AddAccount(new DepositAccount(new IndividualCustomer("Joe Rogan"), 780, 3));
            Console.WriteLine("Type of customer: " + newBank.Accounts[6].Customer.GetType().Name);
            Console.WriteLine("Name: " + newBank.Accounts[6].Customer.Name);
            Console.WriteLine("Balance: " + newBank.Accounts[6].Balance);
            Console.WriteLine("Interest rate: " + newBank.Accounts[6].InterestRate);
        }
Exemple #34
0
        public ActionResult DeleteConfirmed(int id)
        {
            LoanAccount loanAccount = db.LoanAccounts.Find(id);

            db.LoanAccounts.Remove(loanAccount);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #35
0
        /// <summary>
        /// Add a account for a customer
        /// </summary>
        /// <param name="customerNumber"></param>
        /// <param name="typeCode"></param>
        /// <returns></returns>
        public int AddAccount(int customerNumber, Account account)
        {
            using (CWS.SimpleBank.Data.Interview101Entities1 db = new Interview101Entities1())
            {
                var customer = db.Customers.Where(c => c.CustomerNumber == customerNumber).FirstOrDefault();
                if (customer == null)
                {
                    return(0);
                }

                if (account == null)
                {
                    account = new Account();
                }
                account.Balance  = 0M;
                account.TypeCode = "U";
                account.OpenDate = DateTime.Today;

                if (account.GetType() == typeof(LoanAccount))
                {
                    LoanAccount loan = account as LoanAccount;
                    loan.TypeCode     = "L";
                    account.Balance   = loan.OriginalLoanAmount;
                    loan.MaturityDate = DateTime.Today.AddMonths(loan.Term);
                    loan.APR          = 9.99M;

                    customer.Accounts.Add(loan);
                }
                else if (account.GetType() == typeof(CreditCardAccount))
                {
                    CreditCardAccount creditcard = account as CreditCardAccount;
                    creditcard.TypeCode       = "C";
                    creditcard.ExpirationDate = DateTime.Today.AddYears(5);
                    creditcard.PurchaseAPR    = 12.99M;
                    creditcard.CashAPR        = 16.99M;

                    customer.Accounts.Add(creditcard);
                }
                else if (account.GetType() == typeof(CertificateDeposit))
                {
                    CertificateDeposit deposit = account as CertificateDeposit;
                    deposit.TypeCode     = "D";
                    deposit.MaturityDate = DateTime.Today.AddMonths(deposit.Term);
                    deposit.Balance      = deposit.Principal;
                    deposit.APY          = 3.99M;

                    customer.Accounts.Add(deposit);
                }
                else
                {
                    customer.Accounts.Add(account);
                }

                db.SaveChanges();

                return(account.AccountNumber);
            }
        }
Exemple #36
0
        /// <summary>
        /// Create loan account
        /// </summary>
        /// <returns></returns>
        private ILoanAccount createLoanAccount()
        {
            int        period          = Convert.ToInt32(txtPeriod.Text);
            int        unitNumPeriod   = Convert.ToInt32(txtUnitPeriod.Text);
            decimal    percent         = Convert.ToDecimal(txtPercent.Text);
            int        unitNumInterest = Convert.ToInt32(txtUnitInterestRate.Text);
            UnitOfTime unit;

            switch (unitNumPeriod)
            {
            case 0: unit = UnitOfTime.Day;
                break;

            case 1: unit = UnitOfTime.Mounth;
                break;

            case 2: unit = UnitOfTime.Year;
                break;

            default: unit = UnitOfTime.Day;
                break;
            }

            TimePeriod tp = new TimePeriod();

            tp.Period = period;
            tp.Unit   = unit;

            switch (unitNumInterest)
            {
            case 0: unit = UnitOfTime.Day;
                break;

            case 1: unit = UnitOfTime.Mounth;
                break;

            case 2: unit = UnitOfTime.Year;
                break;

            default: unit = UnitOfTime.Day;
                break;
            }

            InterestRate ir = new InterestRate();

            ir.Percent = percent;
            ir.Unit    = unit;

            DateTime start = dtpStart.Value;
            DateTime end   = dtpEnd.Value;

            ITransactionAccount ta = createTransactionAccount();

            ILoanAccount loanAccount = new LoanAccount(ta.Currency, tp, ir, start, end, ta as TransactionAccount);

            return(loanAccount);
        }
Exemple #37
0
 private bool CheckDepositAmount(LoanAccount currAcct, LoanAccount loanAcct)
 {
     if (loanAcct.Balance == 0)
     {
         ModelState.AddModelError("", "Did not specify Deposit Amount");
         return(true);
     }
     return(false);
 }
Exemple #38
0
 public ChargeInstallment(Customer customer, Bank bank, LoanAccount loanAccount, Money amount)
 {
     Bank          = bank;
     this.customer = customer;
     LoanAccount   = loanAccount;
     Money         = amount;
     Status        = OperationStatus.Disposed;
     loanAccount.OtherOperations.Add(this);
 }
Exemple #39
0
 public TakeLoan(Customer customer, Bank bank, LoanAccount loanAccount, Money amount)
 {
     this.bank        = bank;
     this.customer    = customer;
     this.loanAccount = loanAccount;
     Money            = amount;
     Status           = OperationStatus.Disposed;
     loanAccount.OtherOperations.Add(this);
 }
Exemple #40
0
        public void MakeDepositToLoanAccount_CannotDepositNegativeAmount()
        {
            // Arrange
            Individual  personToMakeDeposit = new Individual();
            LoanAccount loan = new LoanAccount(personToMakeDeposit, 0.3, 1000);

            // Act and Assert
            Assert.ThrowsException <ArgumentOutOfRangeException>(() => loan.MakeDeposit(-2));
        }
Exemple #41
0
        public void GetInterestAmountForLoanAccount_MonthsCannotBeLessThanZero()
        {
            // Arrange
            Individual  person = new Individual();
            LoanAccount loan   = new LoanAccount(person, 0.3, 1000);

            // Act and Assert
            Assert.ThrowsException <ArgumentOutOfRangeException>(() => loan.GetInterestAmount(-2));
        }
Exemple #42
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));
        }
Exemple #43
0
    static void Main()
    {
        Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

        Customer depositAccountCustomer = new IndividualCustomer(
            "123456789AA",
            "Pesho",
            "Peshov",
            "Sofia, Bulgaria, Tzarigradsko shose 2",
            "555-123-123");

        DepositAccount depositAccount = new DepositAccount(
            depositAccountCustomer,
            2000,
            0.1234M,
            36);

        Customer loanAccountCustomer = new CorporateCustomer(
            "123456789AB",
            "Oracle Corporation",
            "Sofia, Bulgaria, Tzarigradsko shose 20",
            "555-123-321");

        Account loanAccount = new LoanAccount(
            loanAccountCustomer,
            9000000000,
            0.1234M,
            24);

        Customer mortgageLoanAccountCustomer = new IndividualCustomer(
            "223456789AA",
            "Ginni",
            "Rometty",
            "Sofia, Bulgaria, Tzarigradsko shose 22",
            "555-321-321");

        Account mortgageLoanAccount = new MortgageLoanAccount(
            mortgageLoanAccountCustomer,
            990000,
            0.1234M,
            12);

        decimal depositInterest = depositAccount.CalculateInterest(3);
        Console.WriteLine("Deposit account interest: {0:C2}", depositInterest);

        depositAccount.Deposit(459.76M);
        depositAccount.Withdraw(400.76M);

        Console.WriteLine("Deposit account balance: {0:C2}", depositAccount.Balance);

        decimal loanInterest = loanAccount.CalculateInterest(10);
        Console.WriteLine("Loan account interest: {0:C2}", loanInterest);

        decimal mortgageLoanInterest = mortgageLoanAccount.CalculateInterest(10);
        Console.WriteLine("Mortgage loan account interest: {0:C2}", mortgageLoanInterest);
    }
Exemple #44
0
    static void Main()
    {
        Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

        Customer depositAccountCustomer = new IndividualCustomer(
            "2343PJ34752",
            "William",
            "Harris",
            "1 Microsoft Way, Redmond, WA",
            "1-888-553-6562");

        DepositAccount depositAccount = new DepositAccount(
            depositAccountCustomer,
            2500,
            1.0825M,
            12);

        Customer loanAccountCustomer = new CorporateCustomer(
            "89BPQ123YJ0",
            "Oracle Corporation",
            "500 Oracle Parkway, Redwood Shores, Redwood City, California, United States",
            "1-981-717-9366");

        Account loanAccount = new LoanAccount(
            loanAccountCustomer,
            1000000000,
            1.0931M,
            24);

        Customer mortgageLoanAccountCustomer = new IndividualCustomer(
            "97A20LX3YJU",
            "Ginni",
            "Rometty",
            "Armonk, New York, U.S.",
            "1-129-342-3817");

        Account mortgageLoanAccount = new MortgageLoanAccount(
            mortgageLoanAccountCustomer,
            300000,
            1.0875M,
            36);

        decimal depositInterest = depositAccount.CalculateInterest(3);
        Console.WriteLine("Deposit account interest: {0:C2}", depositInterest);

        depositAccount.Deposit(459.76M);
        depositAccount.Withdraw(400.76M);

        Console.WriteLine("Deposit account balance: {0:C2}", depositAccount.Balance);

        decimal loanInterest = loanAccount.CalculateInterest(10);
        Console.WriteLine("Loan account interest: {0:C2}", loanInterest);

        decimal mortgageLoanInterest = mortgageLoanAccount.CalculateInterest(10);
        Console.WriteLine("Mortgage loan account interest: {0:C2}", mortgageLoanInterest);
    }
        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));
        }
        public LoanAccount ViewAccountById(string appId, string acc)
        {
            LoanAccount account = null;


            account = db.LoanAccounts.ToList().Find(x => x.AppID == appId);


            return(account);
        }
        public void Withdraw_ShouldThrowException()
        {
            // Arrange
            double startingBalance = 200;
            var    loanAccount     = new LoanAccount(owner: "Joe Decker",
                                                     balance: startingBalance);

            // Act, Assert
            Assert.Throws <InvalidOperationException>(() => loanAccount.Withdraw(0));
        }
        private static void TestInterestCalculations(LoanAccount a, MortgageAccount b, MortgageAccount c, DepositAccount d,
            DepositAccount e)
        {
            List<ICalculateInterest> accountInterests = new List<ICalculateInterest>() {a, b, c, d, e};

            foreach (var account in accountInterests)
            {
                Console.WriteLine("{0}, balance {1:F2}", account.GetType().Name, account.CalculateInterest(24));
            }
            Console.WriteLine();
        }
    static void Main()
    {
        LoanAccount loanAcc = new LoanAccount(new Individual("Georgi", 28, "1122334455"), 1000, 7);
        Console.WriteLine(loanAcc.CalculateInterest(6));

        DepositAccount depositAcc = new DepositAccount(new Company("SoftUni Ltd.", 1, "1122334455"), 1000, 7);
        Console.WriteLine(depositAcc.CalculateInterest(6));

        MortgageAccount mortgageAcc = new MortgageAccount(new Individual("Pesho", 20, "1122334455"), 1000, 7);
        Console.WriteLine(mortgageAcc.CalculateInterest(6));
    }
Exemple #50
0
    static void Main(string[] args)
    {
        //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.
        //Your task is to write a program to model the bank system by classes and interfaces. You should
        //identify the classes, interfaces, base classes and abstract actions and implement the calculation
        //of the interest functionality through overridden methods.

        //Make two customers - one company and one individual
        Company kaBar = new Company("KaBar");
        Individual peter = new Individual("Peter Petrov");

        //Make deposite account for individual and company and test the account functionalities
        DepositAccount peterDepositAcount = new DepositAccount(peter, 500m, 0.05m);
        DepositAccount kaBarDepositAcount = new DepositAccount(kaBar, 500m, 0.05m);
        peterDepositAcount.Draw(200m);
        Console.WriteLine(peterDepositAcount.Balance);
        peterDepositAcount.AddDeposit(200);
        Console.WriteLine(peterDepositAcount.Balance);

        Console.WriteLine("The {0} of the {1}-{2} have interest amount for next six mounths: {3} "
            , peterDepositAcount.GetType(), peterDepositAcount.Customer.GetType(), peterDepositAcount.Customer.Name, peterDepositAcount.InterestAmountForPeriod(6));
        Console.WriteLine("The {0} of the {1}-{2} have interest amount for next six mounths: {3} "
            , kaBarDepositAcount.GetType(), kaBarDepositAcount.Customer.GetType(), kaBarDepositAcount.Customer.Name, kaBarDepositAcount.InterestAmountForPeriod(6));
        Console.WriteLine("--------------------------------------------------------------------");

        //Make loan account for individual and company and test the account functionalities
        LoanAccount peterLoanAccount = new LoanAccount(peter, 500m, 0.05m);
        Console.WriteLine("The {0} of the {1}-{2} have interest amount for next six mounths: {3} "
            , peterLoanAccount.GetType(), peterLoanAccount.Customer.GetType(), peterLoanAccount.Customer.Name, peterLoanAccount.InterestAmountForPeriod(6));

        LoanAccount kaBarLoanAccount = new LoanAccount(kaBar, 500m, 0.05m);
        Console.WriteLine("The {0} of the {1}-{2} have interest amount for next six mounths: {3} "
            , kaBarLoanAccount.GetType(), kaBarLoanAccount.Customer.GetType(), kaBarLoanAccount.Customer.Name, kaBarLoanAccount.InterestAmountForPeriod(6));
        Console.WriteLine("--------------------------------------------------------------------");

        //Make Mortage account for individual and company and test the account functionalities
        MortageAccount peterMortageAccount = new MortageAccount(peter, 500m, 0.05m);
        Console.WriteLine("The {0} of the {1}-{2} have interest amount for next two years: {3} "
            , peterMortageAccount.GetType(), peterMortageAccount.Customer.GetType(), peterMortageAccount.Customer.Name, peterMortageAccount.InterestAmountForPeriod(24));
        MortageAccount kaBarMortageAccount = new MortageAccount(kaBar, 500m, 0.05m);
        Console.WriteLine("The {0} of the {1}-{2} have interest amount for next two years: {3} "
            , kaBarMortageAccount.GetType(), kaBarMortageAccount.Customer.GetType(), kaBarMortageAccount.Customer.Name, kaBarMortageAccount.InterestAmountForPeriod(24));
    }
    static void Main()
    {
        //Making customers - individual and company
            CompanyCustomer ood = new CompanyCustomer("OOD");
            IndividualCustomer samuel = new IndividualCustomer("Samuel L. Jackson");

            //Testing some stuff
            DepositAccount samuelDepositAccount = new DepositAccount(samuel , 10000m, 100m);
            DepositAccount oodDepositAccount = new DepositAccount(ood, 10000m, 100m);
            Console.WriteLine("{1} has {0} money.", samuelDepositAccount.Balance, samuelDepositAccount.Customer.Name);
            samuelDepositAccount.WithDrawMoney(500m);
            Console.WriteLine("After we with draw some money he has {0} money." , samuelDepositAccount.Balance);
            samuelDepositAccount.AddDeposit(200m);
            Console.WriteLine("After we deposit some money he has " + samuelDepositAccount.Balance);

            Console.WriteLine();
            Console.WriteLine();

            //Testing the deposit account
            Console.WriteLine("Testing the deposit account:");
            Console.WriteLine("----------------------------");
            Console.WriteLine("The {0} of {2} who is a {1} has interest amount for next 6 mounths: {3} "
            , samuelDepositAccount.GetType(), samuelDepositAccount.Customer.GetType(), samuelDepositAccount.Customer.Name, samuelDepositAccount.InterestAmountForPeriod(6));
            Console.WriteLine("The {0} of {2} who is a {1} has interest amount for next 6 mounths: {3} "
                , oodDepositAccount.GetType(), oodDepositAccount.Customer.GetType(), oodDepositAccount.Customer.Name, oodDepositAccount.InterestAmountForPeriod(6));
            Console.WriteLine();
            Console.WriteLine();

            //Testing the loan account
            Console.WriteLine("Testing the loan account:");
            Console.WriteLine("----------------------------");
            LoanAccount samuelLoanAccount = new LoanAccount(samuel, 10000m, 100m);
            Console.WriteLine("The {0} of {2} who is a {1} has interest amount for next 6 mounths: {3} "
                , samuelLoanAccount.GetType(), samuelLoanAccount.Customer.GetType(), samuelLoanAccount.Customer.Name, samuelLoanAccount.InterestAmountForPeriod(6));

            LoanAccount oodLoanAccount = new LoanAccount(ood, 10000m, 100m);
            Console.WriteLine("The {0} of {2} who is a {1} has interest amount for next 6 mounths: {3} "
                , oodLoanAccount.GetType(), oodLoanAccount.Customer.GetType(), oodLoanAccount.Customer.Name, oodLoanAccount.InterestAmountForPeriod(6));
            Console.WriteLine();
            Console.WriteLine();

            //Testing the mortage account
            Console.WriteLine("Testing the mortage account:");
            Console.WriteLine("----------------------------");
            MortageAccount samuelMortageAccount = new MortageAccount(samuel, 10000m, 100m);
            Console.WriteLine("The {0} of {2} who is a {1} has interest amount for next 24 mounths: {3} "
                , samuelMortageAccount.GetType(), samuelMortageAccount.Customer.GetType(), samuelMortageAccount.Customer.Name, samuelMortageAccount.InterestAmountForPeriod(24));
            MortageAccount oodMortageAccount = new MortageAccount(ood, 10000m, 100m);
            Console.WriteLine("The {0} of {2} who is a {1} has interest amount for next 24 mounths: {3} "
                , oodMortageAccount.GetType(), oodMortageAccount.Customer.GetType(), oodMortageAccount.Customer.Name, oodMortageAccount.InterestAmountForPeriod(24));
    }
        private static void TestDepositFunctionality(LoanAccount a, MortgageAccount b, MortgageAccount c, DepositAccount d,
            DepositAccount e)
        {
            List<IDepositMoney> accountDeposits = new List<IDepositMoney>() {a, b, c, d, e};

            foreach (var deposit in accountDeposits)
            {
                deposit.DepositMoney(1100.50m);

                Account acc = (Account) deposit;
                Console.WriteLine("{0}, balance {1:F2}", acc.GetType().Name, acc.Balance);
            }
            Console.WriteLine();
        }
Exemple #53
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);
            }
        }
    static void Main()
    {
        Console.WriteLine("----------Loan Account(Company)----------\n");
        LoanAccount accountOne = new LoanAccount(CustomerType.Company, 50000, 500, 24);
        accountOne.CalculateInterest();
        accountOne.Deposit(500);

        Console.WriteLine("\n\n----------Loan Account(Individual)----------\n");
        LoanAccount accountTwo = new LoanAccount(CustomerType.Individual, 50000, 500, 24);
        accountTwo.CalculateInterest();
        accountTwo.Deposit(500);

        Console.WriteLine("\n\n----------Mortage Account(Company)----------\n");
        MortageAccount accountThree = new MortageAccount(CustomerType.Company, 100000, 1000, 36);
        accountThree.CalculateInterest();
        accountThree.Deposit(10000);

        Console.WriteLine("\n\n----------Mortage Account(Individual)----------\n");
        MortageAccount accountFour = new MortageAccount(CustomerType.Individual, 100000, 1000, 36);
        accountFour.CalculateInterest();
        accountFour.Deposit(10000);

        Console.WriteLine("\n\n----------Deposit Account(Company)----------\n");
        DepositAccount accountFive = new DepositAccount(CustomerType.Company, 500000, 5000, 24);
        accountFive.CalculateInterest();
        accountFive.Deposit(100000);
        accountFive.Withdraw(200000);

        Console.WriteLine("\n\n----------Deposit Account(Individual)----------\n");
        DepositAccount accountSix = new DepositAccount(CustomerType.Individual, 500000, 5000, 24);
        accountSix.CalculateInterest();
        accountSix.Deposit(100000);
        accountSix.Withdraw(200000);

        Console.WriteLine("\n\n----------Deposit Account(Balance under 1000)----------\n");
        DepositAccount accountSeven = new DepositAccount(CustomerType.Individual, 500, 50, 6);
        accountSeven.CalculateInterest();
        accountSeven.Deposit(50);
        accountSeven.Withdraw(150);

        Console.WriteLine("\n\n\n");
    }
Exemple #55
0
    static void Main()
    {
        Console.WriteLine("Mortage account");
        MortageAccount mort = new MortageAccount(CustumerType.Individual, 344, 0.006);
        double interAmount = mort.InterestAmount(12);
        Console.WriteLine("The interest amount for the first year is {0:0.00}%", interAmount * 100);
        Console.WriteLine();

        Console.WriteLine("Loan account");
        LoanAccount loan = new LoanAccount(CustumerType.Company, 1500, 0.009);
        interAmount = loan.InterestAmount(24);
        Console.WriteLine("The interest amount for the first two years is {0:0.00}%", interAmount * 100);
        Console.WriteLine();

        Console.WriteLine("Deposit account");
        DepositAccount deposit = new DepositAccount(CustumerType.Company, 1200, 0.007);
        interAmount = deposit.InterestAmount(6);
        Console.WriteLine("The interest amount for the first 6 monts is {0:0.00}%", interAmount * 100);
        Console.WriteLine();
    }
        static void Main()
        {
            var a = new LoanAccount(new Company("M-tel", "Sofia", "0987654321"), 100000, 0.01m);

            var b = new MortgageAccount(new Individual("Petar Georgiev", "Sofia", 32), 10000, 0.01m);

            var c = new MortgageAccount(new Company("M-tel", "Sofia", "0987654321"), 100000, 0.01m);

            var d = new DepositAccount(new Individual("Stamat Stamatov", "Burgas", 44), 100, 0.005m);

            var e = new DepositAccount(new Individual("Minka Stamatova", "Burgas", 42), 1000, 0.005m);

            //1. Test interest rate calculations:
            TestInterestCalculations(a, b, c, d, e);

            //2. Test deposit functionality:
            TestDepositFunctionality(a, b, c, d, e);

            //3. Test withdraw functionality:
            TestWithdrawFunctionality(d, e);
        }
    static void Main()
    {
        // Customers
        Customer[] customers = new Customer[4];
        customers[0] = new IndividualCustomer("Iliqn Petrov", 59784, "0894719648");
        customers[1] = new CompanieCustomer("Kiril Iliev", 81746, "0881446720");
        customers[2] = new IndividualCustomer("Nikolai Grancharov", 91002, "0874100359");
        customers[3] = new CompanieCustomer("Kiril Slavqnov", 00147, "0886979231");

        // Accounts
        DepositAccount firstDeposit = new DepositAccount(customers[0], 3000, 0.10m, 12);

        BankAccount[] accounts = new BankAccount[5];
        accounts[0] = firstDeposit;
        accounts[1] = new LoanAccount(customers[1], 5000, 0.08m, 6);
        accounts[2] = new LoanAccount(customers[2], 5000, 0.08m, 6);
        accounts[3] = new MortgageAccount(customers[2], 22900, 0.11m, 48);
        accounts[4] = new MortgageAccount(customers[3], 22900, 0.11m, 48);

        // Print 1
        Console.ForegroundColor = ConsoleColor.Green;
        Console.WriteLine("First Print ...");
        Console.ResetColor();
        foreach (var item in accounts)
        {
            Console.WriteLine(item);
            Console.WriteLine();
        }

        // Withdraw & Deposit
        firstDeposit.Withdraw(250);
        firstDeposit.Deposit(600);

        // Print 2
        Console.ForegroundColor = ConsoleColor.Green;
        Console.WriteLine("Second Print ...");
        Console.ResetColor();
        Console.WriteLine(accounts[0]);
        Console.ReadLine();
    }
Exemple #58
0
 public static void Main()
 {
     var testAcount = new DepositAccount(new Company("Abc", "040304123"), 3.47m);
     Console.WriteLine(testAcount);
     Console.WriteLine(testAcount.Deposit(1200m));
     Console.WriteLine(testAcount.Withdraw(101m));
     Console.WriteLine("Interest: " + testAcount.CalculateInterest(10));
     Console.WriteLine(testAcount);
     Console.WriteLine(new string('-', 60));
     var anotherTestAccount = new MortgageAccount(new Company("Apple", "040304123"), 5);
     Console.WriteLine(anotherTestAccount);
     Console.WriteLine(anotherTestAccount.Deposit(120m));
     Console.WriteLine("Interest:" + anotherTestAccount.CalculateInterest(13));
     Console.WriteLine(anotherTestAccount);
     Console.WriteLine(new string('-', 60));
     var yetAnotherTestAccount = new LoanAccount(new Individual("Gosho","8010271234"),4.2m);
     Console.WriteLine(yetAnotherTestAccount);
     Console.WriteLine(yetAnotherTestAccount.Deposit(180m));
     Console.WriteLine("Interest: " + yetAnotherTestAccount.CalculateInterest(3));
     Console.WriteLine(yetAnotherTestAccount);
     Console.WriteLine(new string('-', 60));
 }
        public static void Main()
        {
            // These examples and most of the solutions for the classes are taken from the forum
            // I actually "did read" all of the code and changed a couple of things

            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}: {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 #60
-1
        public static void Main()
        {
            Bank bank = new Bank("SoftUni Bank");
            var e = bank.Accounts;
            foreach (var account in e)
            {
                Console.WriteLine(account);
            }

            try
            {
                Individual clientOne = new Individual("Pencho Pitankata", "Neyde", "1212121230");
                Company clientTwo = new Company("SoftUni", "Hadji Dimitar", "831251119", true);
                DepositAccount depositOne = new DepositAccount(clientOne, 5, 10000);
                DepositAccount depositTwo = new DepositAccount(clientOne, 2, 100, new DateTime(2000, 01, 01));
                DepositAccount depositThree = new DepositAccount(clientOne, 2, 10000, new DateTime(2008, 01, 01));
                LoanAccount loanOne = new LoanAccount(clientOne, 14, 10000, new DateTime(2003, 01, 01));
                LoanAccount loanTwo = new LoanAccount(clientTwo, 14, 10000, new DateTime(2003, 01, 01));
                MortgageAccount mortgageOne = new MortgageAccount(clientOne, 7, 100000, new DateTime(2013, 08, 01));
                MortgageAccount mortgageTwo = new MortgageAccount(clientTwo, 7, 100000, new DateTime(2014, 08, 01));
                Console.WriteLine("Deposit Account 1 Interest: {0:F2}", depositOne.Interest());
                Console.WriteLine("Deposit Account 2 Interest: {0:F2}", depositTwo.Interest());
                Console.WriteLine("Deposit Account 3 Interest: {0:F2}", depositThree.Interest());
                Console.WriteLine("Loan Account Individual Interest: {0:F2}", loanOne.Interest());
                Console.WriteLine("Loan Account Company Interest: {0:F2}", loanTwo.Interest());
                Console.WriteLine("Mortgage Account Interest: {0:F2}", mortgageOne.Interest());
                Console.WriteLine("Mortgage Account Interest: {0:F2}", mortgageTwo.Interest());
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
            }
        }