Ejemplo n.º 1
0
        public static void Main()
        {
            Loan individualLoad = new Loan()
            {
                Balance             = 1505.20m,
                Customer            = new Individual(),
                MonthlyInterestRate = 12.3m
            };

            var individualLoanInterestForSixMonths = individualLoad.CalculateInterest(new IndividualLoanProvider(), 6);

            Console.WriteLine("12.3 * 6 = " + 12.3m * 6);
            Console.WriteLine("12.3 * (6-3) = " + individualLoanInterestForSixMonths);

            Mortgage individualMortgage = new Mortgage()
            {
                Balance             = 123.123m,
                Customer            = new Individual(),
                MonthlyInterestRate = 9.5m
            };

            var individualMortgageInterestForEightMonths = individualMortgage.CalculateInterest(new IndividualMortgageProvider(), 8);

            Console.WriteLine("9.5 * 8 = " + 9.5m * 8);
            Console.WriteLine("9.5 * (8-6) = " + individualMortgageInterestForEightMonths);
        }
Ejemplo n.º 2
0
    static void Main()
    {
        Deposit deposit = new Deposit(new Individual("Phili Fry"), 5000m, 5);
        deposit.DepositIn(1000m);
        Console.WriteLine(deposit.Balance);
        deposit.Withdraw(1500m);
        Console.WriteLine(deposit.Balance);
        Console.WriteLine(deposit.CalculateInterest(5));

        Console.WriteLine("-------------------");

        Loan loan = new Loan(new Individual("James"), 2000m, 20);
        loan.DepositIn(2000m);
        Console.WriteLine(loan.Balance);
        Console.WriteLine(loan.CalculateInterest(5));

        Console.WriteLine("-------------------");

        Loan companyLoan = new Loan(new Company("Telecom"), 2000m, 20);
        companyLoan.DepositIn(3000m);
        Console.WriteLine(companyLoan.Balance);
        Console.WriteLine(companyLoan.CalculateInterest(5));

        Console.WriteLine("-------------------");

        Mortgage mortgage = new Mortgage(new Individual("Bart"), 2000m, 20);
        mortgage.DepositIn(3000m);
        Console.WriteLine(mortgage.Balance);
        Console.WriteLine(mortgage.CalculateInterest(8));

        Console.WriteLine("-------------------");

        Mortgage companyMortgate = new Mortgage(new Company("Airline"), 2000m, 20);
        Console.WriteLine(companyMortgate.CalculateInterest(16));
    }
 static void Main()
 {
     Console.WriteLine("Enter number");
     int number = int.Parse(Console.ReadLine());
     try
     {
         for (int count = 0; count < number; count++)
         {
             Console.WriteLine("Enter customer kind");               //true equals to individual, and false to company
             bool customerKind = bool.Parse(Console.ReadLine());
             Console.WriteLine("Enter customer name");
             string customerName = Console.ReadLine();
             Customer customer = new Customer(customerKind, customerName);
             Console.WriteLine("Enter interest rate");
             float currentInterestRate = float.Parse(Console.ReadLine());
             Console.WriteLine("Enter account balance");
             double currentBalance = double.Parse(Console.ReadLine());
             Deposit deposit = new Deposit(customer, currentInterestRate, currentBalance);
             Loan loan = new Loan(customer, currentInterestRate, currentBalance);
             Mortgage mortgage = new Mortgage(customer, currentInterestRate, currentBalance);
             Console.WriteLine("Enter start month");
             byte startMonth = byte.Parse(Console.ReadLine());
             Console.WriteLine("Enter end month");
             byte endMonth = byte.Parse(Console.ReadLine());
             Console.WriteLine("Interest for the deposit is {0}", deposit.CalculateInterest(startMonth, endMonth));
             Console.WriteLine("Interest for the loan is {0}", loan.CalculateInterest(startMonth, endMonth));
             Console.WriteLine("Interest for the morgage is {0}", mortgage.CalculateInterest(startMonth, endMonth));
         }
     }
     catch (ArgumentException ae)
     {
         Console.WriteLine(ae.Message);
     }
 }
        static void Main(string[] args)
        {
            try
            {
                Deposit deposit = new Deposit(Customer.Company, 20000m, 3.4m);
                deposit.Withdraw(345m);
                deposit.DepositMoney(1000m);
                deposit.CalculateInterest(10);
                Console.WriteLine("Deposit:\n{0}", deposit);

                Loan loanIndividual = new Loan(Customer.Individual, 1000m, 20m);
                loanIndividual.DepositMoney(3000m);
                loanIndividual.CalculateInterest(5);
                Console.WriteLine("Loan individual:\n{0}", loanIndividual);

                Loan loanCompalny = new Loan(Customer.Company, 200000m, 5m);
                loanCompalny.DepositMoney(30000m);
                loanCompalny.CalculateInterest(4);
                Console.WriteLine("Loan company:\n{0}", loanCompalny);

                Mortgage mortageIndividual = new Mortgage(Customer.Individual, 500, 3.3m);
                mortageIndividual.DepositMoney(200m);
                mortageIndividual.CalculateInterest(7);
                Console.WriteLine("Mortage individual:\n{0}", mortageIndividual);

                Mortgage mortageCompany = new Mortgage(Customer.Company, 50000, 4m);
                mortageIndividual.DepositMoney(2000m);
                mortageIndividual.CalculateInterest(13);
                Console.WriteLine("Mortage individual:\n{0}", mortageIndividual);
            }
            catch (OverflowException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (ArgumentOutOfRangeException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            Deposit deposit = new Deposit(new Individual("me", 123), 499, 0.1m, 2);

            Console.WriteLine(deposit.InterestRate);
            deposit.Deposit(10);
            Console.WriteLine(deposit.Balance);
            Loan myLoan = new Loan(new Company("MT", 11), 1000, 0.3m, 2);

            Console.WriteLine(myLoan.CalculateInterest());
            var morgage = new Mortgage(new Individual("me again", 1), 1000, 0.1m, 7);

            Console.WriteLine(morgage.CalculateInterest());
            morgage = new Mortgage(new Company("me ET", 1), 2000, 0.4m, 7);
            Console.WriteLine(morgage.CalculateInterest());
        }
Ejemplo n.º 6
0
        public static void Main()
        {
            Console.Title = "Problem 2.	Bank of Kurtovo Konare";

            Deposit goshoDeposit = new Deposit(Customer.Individuals, 1000m, 0.05m);
            goshoDeposit.DepositMoney(450);
            goshoDeposit.WithdrawMoney(400);
            Console.WriteLine(goshoDeposit + "Interest = " + goshoDeposit.CalculateInterest(10));
            Console.WriteLine();

            Loan carskiZaem = new Loan(Customer.Companies, 50000m, 0.1m);
            carskiZaem.DepositMoney(1);
            Console.WriteLine(carskiZaem + "Interest = " + carskiZaem.CalculateInterest(5));
            Console.WriteLine();

            Mortgage bmwPesho = new Mortgage(Customer.Individuals, 10000m, 0.01m);
            bmwPesho.DepositMoney(5000);
            Console.WriteLine(bmwPesho + "Interest = " + bmwPesho.CalculateInterest(30));
        }
Ejemplo n.º 7
0
    static void Main()
    {
        // Innstance of an individual and a Company customer
        Customer cust1 = new Individual("Misho", "Sofia", "541010");
        Customer cust2 = new Company("Albireo", "Plovdiv", "BG1211121121");

        // Deposit account-Individual customer
        Deposit account01 = new Deposit(cust1, 0.5);
        Console.WriteLine("Open new deposit for Individual. Starting ammount ->{0}", account01.Balance);
        account01.DepositMoney(1500);
        Console.WriteLine("Deposit 1500. Ammount ->{0}", account01.Balance);
        account01.WithdrawMoney(400);
        Console.WriteLine("Withdraw 400. Ammount ->{0}", account01.Balance);

        account01.CalculateInterest(5);
        Console.WriteLine("Calculate interest of {1}% for 5 months. Ammount ->{0}", account01.Balance, account01.InterestRate);
        account01.WithdrawMoney(600);
        Console.WriteLine("Withdraw 600. Ammount ->{0}", account01.Balance);
        account01.CalculateInterest(3);

        // 0% interest when balance is below 1000
        Console.WriteLine("Calculate interest of {1}% for 3 months. Ammount ->{0}", account01.Balance, account01.InterestRate);
        Console.WriteLine();

        //Loan account - Company
        Loan account02 = new Loan(cust2, 11000, 1);
        Console.WriteLine("Open new loan for a company. Ammount -> {0}", account02.Balance);
        account02.DepositMoney(3000);
        Console.WriteLine("Deposit 3000. Ammount -> {0}", account02.Balance);
        account02.CalculateInterest(2);
        // 0% interest or the first 2 months
        Console.WriteLine("Calculate interest of {1}% for 2 months. Ammount ->{0}", account02.Balance, account02.InterestRate);
        account02.CalculateInterest(5);
        Console.WriteLine("Calculate interest of {1}% for 5 months. Ammount ->{0}", account02.Balance, account02.InterestRate);
        Console.WriteLine();

        //Loan Account - Individual
        Loan account03 = new Loan(cust1, 1000, 1.2);
        Console.WriteLine("Open new loan for an individual. Ammount -> {0}", account03.Balance);
        account03.DepositMoney(100);
        Console.WriteLine("Deposit 100. Ammount -> {0}", account03.Balance);
        // 0% interest or the first 3 months
        account03.CalculateInterest(3);
        Console.WriteLine("Calculate interest of {1}% for 3 months. Ammount ->{0}", account03.Balance, account03.InterestRate);
        account03.CalculateInterest(5);
        Console.WriteLine("Calculate interest of {1}% for 5 months. Ammount ->{0}", account03.Balance, account03.InterestRate);
        Console.WriteLine();

        //Mortgage account - Individual
        Mortgage account04 = new Mortgage(cust1, 50000, 0.6);
        Console.WriteLine("Open new mortgage for an individual. Ammount -> {0}", account04.Balance);
        // 0% interest or the first 6 months
        account04.CalculateInterest(6);
        Console.WriteLine("Calculate interest of {1}% for 6 months. Ammount ->{0}", account04.Balance, account04.InterestRate);
        account04.CalculateInterest(7);
        Console.WriteLine("Calculate interest of {1}% for 7 months. Ammount ->{0}", account04.Balance, account04.InterestRate);
        account04.DepositMoney(1500);
        Console.WriteLine("Deposit 1500. Ammount -> {0}", account04.Balance);
        Console.WriteLine();

        // Mortgage account - Company
        Mortgage account05 = new Mortgage(cust2, 500000, 0.4);
        Console.WriteLine("Open new mortgage for a company. Ammount -> {0}", account05.Balance);
        account05.CalculateInterest(10);
        Console.WriteLine("Calculate interest of {1}% for 10 months. Ammount ->{0}", account05.Balance, account05.InterestRate);
        account05.CalculateInterest(15);
        Console.WriteLine("Calculate interest of {1}% for 15 months. Ammount ->{0}", account05.Balance, account05.InterestRate);
        account05.DepositMoney(5000);
        Console.WriteLine("Deposit 5000. Ammount -> {0}", account05.Balance);
    }