Example #1
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));
    }
        static void Main(string[] args)
        {
            DepositAccount account;

            // Deposit Ivan Ivanov
            account = new DepositAccount(new IndividualCustomer("Ivan", "Ivanov"), 0m, 3.1m);
            Console.WriteLine(account);
            Console.WriteLine("Interest rate for 3 months is " + account.CalculateInterest(3));
            Console.WriteLine("Deposit 1000");
            account.Deposit(1000);
            System.Console.WriteLine(account);
            Console.WriteLine("Interest rate for 3 months is " + account.CalculateInterest(3));

            // Deposit company Apple
            account = new DepositAccount(new CompanyCustomer("Apple"), 0m, 1m);
            Console.WriteLine(account);
            Console.WriteLine("Interest rate for 3 months is " + account.CalculateInterest(3));
            Console.WriteLine("Deposit 1000000");
            account.Deposit(1000000);
            System.Console.WriteLine(account);
            Console.WriteLine("Interest rate for 3 months is " + account.CalculateInterest(3));

            LoanAccount account1;

            // Loan Microsoft
            account1 = new LoanAccount(new CompanyCustomer("Microsoft"), 1000000m, 3m);
            Console.WriteLine(account1);
            Console.WriteLine("Interest rate for 3 months is " + account1.CalculateInterest(3));
            Console.WriteLine("Deposit 1000");
            account1.Deposit(1000);
            System.Console.WriteLine(account1);
            Console.WriteLine("Interest rate for 3 months is " + account1.CalculateInterest(3));

            MortageAccount account2;

            // Loan Atanas Georgiev
            account2 = new MortageAccount(new IndividualCustomer("Atanas", "Georgiev"), 10000m, 5.1m);
            Console.WriteLine(account2);
            Console.WriteLine("Interest rate for 3 months is " + account2.CalculateInterest(3));
            Console.WriteLine("Deposit 1000");
            account2.Deposit(1000);
            System.Console.WriteLine(account2);
            Console.WriteLine("Interest rate for 13 months is " + account2.CalculateInterest(13));
        }
    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");
    }
Example #5
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();
    }
Example #6
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();
    }
Example #7
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));
    }