Example #1
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));
    }
Example #2
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));
    }
Example #3
0
        public static void Main()
        {
            DepositAccount  depositAcc  = new DepositAccount(new Customer(CustomerType.Company), 1000m, 5.7m);
            LoanAccount     loanAcc     = new LoanAccount(new Customer(CustomerType.Individual), 5000m, 7m);
            MortgageAccount mortgageAcc = new MortgageAccount(new Customer(CustomerType.Individual), 100000m, 5m);

            Console.WriteLine(depositAcc.CalculateInterest(2) + "%");
            Console.WriteLine(loanAcc.CalculateInterest(24) + "%");
            Console.WriteLine(mortgageAcc.CalculateInterest(15) + "%");

            depositAcc.WithdrawMoney(200m);
            Console.WriteLine(depositAcc.Balance);

            loanAcc.DepositMoney(900m);
            Console.WriteLine(loanAcc.Balance);
        }
Example #4
0
        static void Main()
        {
            // Creating some customers
            IndividualCustomer customer1 = new IndividualCustomer("Ivan", "Ivanov", 11223344);
            CompanyCustomer    customer2 = new CompanyCustomer("Company 0101", 99887766);
            CompanyCustomer    customer3 = new CompanyCustomer("Company 123", 22334455);

            // Creating different kinds of accounts
            DepositAccount account1 = new DepositAccount(customer1, 20000m, 10m);
            LoanAccount    account2 = new LoanAccount(customer2, 5000m, 6.8m);
            DepositAccount account3 = new DepositAccount(customer3, 3400m, 16.4m);

            // Creating the bank with the accounts
            List <Account> accounts = new List <Account>()
            {
                account1, account2, account3
            };
            Bank bank = new Bank("G Bank", accounts);

            // Adding account to the bank
            IndividualCustomer customer4 = new IndividualCustomer("Georgi", "Georgiev", 66778800);
            MortgageAccount    account4  = new MortgageAccount(customer4, 2000m, 4.1m);

            bank.AddAccount(account4);

            // Printing all the information about the bank and its clients on the console
            Console.WriteLine(bank);

            // Depositting and withdrawing money to account1
            account1.DepositMoney(100m);
            account1.WithdrawMoney(2000m);
            Console.WriteLine("After depositting and withdrawing money from {0} {1}'s account the balance is: {2:C2}",
                              customer1.Fname, customer1.Lname, account1.Balance);
            Console.WriteLine();

            // Calculating the interest amount for all the accounts in the bank
            Console.WriteLine("Deposit account interest amount after 5 months: {0:C2}", account1.CalculateInterestAmount(5));
            account3.WithdrawMoney(2600m);
            Console.WriteLine("Deposit account interest amount after 2 months: {0:C2}", account3.CalculateInterestAmount(2));
            Console.WriteLine("Loan account interest amount after 10 months: {0:C2}", account2.CalculateInterestAmount(10));
            Console.WriteLine("Mortgage account interest amount after 1 year: {0:C2}", account4.CalculateInterestAmount(12));
        }
Example #5
0
        static void Main()
        {
            //in my opition accounts should have DateTime property "startDate" or something for
            //the time of the account openning nad months should be calculated with DateTime.Now - startDate
            //but we cannot test the program this way, so months are entered in the constructors
            //
            //Also calculate interest should add the interest to the main balance but I did not add that because
            //in the task is not exactly clear

            DepositAccount deposit = new DepositAccount(new Individual("Pesho", 21, "Male"), 7.5m, 15);

            deposit.DepositMoney(10000m);
            System.Console.WriteLine(deposit.CalculateInterest());
            deposit.WithdrawMoney(5000m);
            System.Console.WriteLine(deposit.Balance);

            LoanAccount loan = new LoanAccount(new Company("Pesho ltd.", "00000153265"), 5.5m, 10);

            loan.DepositMoney(50000m);
            System.Console.WriteLine(loan.CalculateInterest());
        }