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));
    }
    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 #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()
        {
            // 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 #5
0
    static void Main()
    {
        Customer customer = Customer.Individual;
          DepositAccount account = new DepositAccount(customer, 1500, 5);

          Console.WriteLine(account.CalculateInterest(5));

          account.DepositMoney(2500);
          account.WithDraw(500);
          Console.WriteLine(account.Balance);
    }
Exemple #6
0
        public void TestMethod1()
        {
            //arrange
            Account CurrentAccount1 = new DepositAccount("Рогатнев", "Сергей");
            decimal AddSum          = 1000;

            //act
            CurrentAccount1.DepositMoney(AddSum);

            //assert
            Assert.AreEqual(AddSum, CurrentAccount1.Amount);
        }
Exemple #7
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));
        }
Exemple #8
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());
        }
Exemple #9
0
        static void Main()
        {
            IndividualCustomer Bobo  = new IndividualCustomer("Bobo");
            CompanyCustomer    Komfo = new CompanyCustomer("Komfo");

            DepositAccount firstDeposit  = new DepositAccount(Bobo, 800, 15);
            LoanAccoint    secondDeposit = new LoanAccoint(Komfo, 2299, 19);

            Console.WriteLine("Balance {0}: {1:#.##} lv.; Interest: {2:0.##}"
                              , firstDeposit.Customer.Name, firstDeposit.Balance, firstDeposit.CalculateInterest(12));

            firstDeposit.DepositMoney(600);
            Console.WriteLine("Balance {0}: {1:#.##} lv.; Interest: {2:0.##}"
                              , firstDeposit.Customer.Name, firstDeposit.Balance, firstDeposit.CalculateInterest(12));


            Console.WriteLine("Balance {0}: {1:#.##} lv.; Interest: {2:0.##}"
                              , secondDeposit.Customer.Name, secondDeposit.Balance, secondDeposit.CalculateInterest(2));

            Console.WriteLine();
            Console.WriteLine("Balance {0}: {1:#.##} lv.; Interest: {2:0.##}"
                              , secondDeposit.Customer.Name, secondDeposit.Balance, secondDeposit.CalculateInterest(6));

            MortgageAccount death = new MortgageAccount(Bobo, 750, 15);
            MortgageAccount metal = new MortgageAccount(Komfo, 1000, 15);

            Console.WriteLine("Balance {0}: {1:#.##} lv.; Interest: {2:0.##}"
                              , death.Customer.Name, death.Balance, death.CalculateInterest(6));
            Console.WriteLine("Balance {0}: {1:#.##} lv.; Interest: {2:0.##}"
                              , death.Customer.Name, death.Balance, death.CalculateInterest(7));
            Console.WriteLine();

            Console.WriteLine("Balance {0}: {1:#.##} lv.; Interest: {2:0.##}"
                              , metal.Customer.Name, metal.Balance, metal.CalculateInterest(12));
            Console.WriteLine("Balance {0}: {1:#.##} lv.; Interest: {2:0.##}"
                              , metal.Customer.Name, metal.Balance, metal.CalculateInterest(24));
        }