Пример #1
0
    static void Main(string[] args)
    {
        //Pesho's Account
        Deposit peshosAccount = new Deposit(new Individual("Pesho"), 100000m, 25.3f);

        Console.WriteLine("Pesho's current balance: {0}", peshosAccount.Balance);
        Console.WriteLine("Pesho's interest amount: {0}", peshosAccount.CalculateInterestAmount(12));
        //Add some money in the Pesho's account
        peshosAccount.Deposit(2131m);
        Console.WriteLine("Pesho's balance after the deposit: {0}", peshosAccount.Balance);
        peshosAccount.WithDraw(35000m);
        Console.WriteLine("Pesho's balance after the draw: {0}", peshosAccount.Balance);

        //Let us calculate the Pesho's interest amount
        Console.WriteLine("Pesho's account interest amount: {0}", peshosAccount.CalculateInterestAmount(4));
        Console.WriteLine();
        
        //Ivan's Account
        Account ivansAccount = new Loan(new Company("Ivan"), 1040.4m, 23.3f);
        
        Console.WriteLine("Ivan's interest amount: {0}", ivansAccount.CalculateInterestAmount(7));
        Console.WriteLine();
        
        //Dido's Account
        Account didosAccount = new Mortgage(new Individual("Dido"), 3422m, 5.4f);
        Console.WriteLine("Ivan's interest amount: {0}", didosAccount.CalculateInterestAmount(13));
    }
Пример #2
0
 static void Main()
 {
     //Deposit test
     Console.WriteLine("Deposit account test:");
     Deposit deposit = new Deposit(Customer.Individual, 2000m, 12.3m);
     Console.Write("Deposite interest for 3 months and 12.3 interest rate = ");
     Console.WriteLine(deposit.CalculateInterestAmount(3));
     Console.WriteLine();
     //Loan test
     Console.WriteLine("Loan account test:");
     Loan loanIndividual = new Loan(Customer.Individual, 1000m, 1.2m);
     Loan loanCompany = new Loan(Customer.Company, 4000m, 3.3m);
     Console.Write("Individual interest for 4 months and 1.2 interest rate = ");
     Console.WriteLine(loanIndividual.CalculateInterestAmount(4));
     Console.Write("Company interest for 3 months and 3.3 interest rate = ");
     Console.WriteLine(loanCompany.CalculateInterestAmount(3));
     Console.WriteLine();
     //Mortgage test
     Console.WriteLine("Mortgage account test:");
     Mortgage mortgageIndividual = new Mortgage(Customer.Individual, 40000m, 5.4m);
     Mortgage mortgageCompany = new Mortgage(Customer.Company, 120000m, 6.5m);
     Console.Write("Individual interest for 4 months and {0} interest rate = ", mortgageIndividual.InterestRate);
     Console.WriteLine(mortgageIndividual.CalculateInterestAmount(4));
     Console.Write("Individual interest for 15 months and 5.4 interest rate = ");
     Console.WriteLine(mortgageIndividual.CalculateInterestAmount(15));
     Console.Write("Company interest for 3 months and 6.5 interest rate = ");
     Console.WriteLine(mortgageCompany.CalculateInterestAmount(3));
 }
Пример #3
0
        static void Main()
        {
            Customer pesho = new Individual("Pesho");
            Customer firmataNaPesho = new Company("Pesho Inc");

            Account loan1 = new Loan(pesho,12.2M);
            Account loan2 = new Loan(firmataNaPesho, 12.2M);

            loan1.DepositMoney(1000M);
            loan2.DepositMoney(1000M);

            System.Console.WriteLine(string.Format("Loan {0}. Interest amount: {1:C}", loan1.Customer.Name, loan1.CalculateInterestAmount(24)));
            System.Console.WriteLine(string.Format("Loan {0}. Interest amount: {1:C}", loan2.Customer.Name, loan2.CalculateInterestAmount(24)));

            Account deposit1 = new Deposit(pesho, 13M);
            Account deposit2 = new Deposit(firmataNaPesho, 13M);

            deposit1.DepositMoney(15M);
            deposit2.DepositMoney(2000M);

            System.Console.WriteLine(string.Format(
                "Deposit {0}. Interest amount: {1:C}", deposit1.Customer.Name, deposit1.CalculateInterestAmount(24)));
            System.Console.WriteLine(string.Format(
                "Deposit {0}. Interest amount: {1:C}", deposit2.Customer.Name, deposit2.CalculateInterestAmount(24)));

            Account mortage1 = new Mortgage(pesho, 10.2M);
            Account mortage2 = new Mortgage(firmataNaPesho , 10.2M);

            mortage1.DepositMoney(200M);
            mortage2.DepositMoney(200M);

            System.Console.WriteLine(string.Format(
                "Mortage {0}. Interest amount: {1:C}", mortage1.Customer.Name, mortage1.CalculateInterestAmount(24)));
            System.Console.WriteLine(string.Format(
                "Mortage {0}. Interest amount: {1:C}", mortage2.Customer.Name, mortage2.CalculateInterestAmount(24)));
        }
Пример #4
0
        static void Main()
        {
            Customer pesho          = new Individual("Pesho");
            Customer firmataNaPesho = new Company("Pesho Inc");

            Account loan1 = new Loan(pesho, 12.2M);
            Account loan2 = new Loan(firmataNaPesho, 12.2M);

            loan1.DepositMoney(1000M);
            loan2.DepositMoney(1000M);

            System.Console.WriteLine(string.Format("Loan {0}. Interest amount: {1:C}", loan1.Customer.Name, loan1.CalculateInterestAmount(24)));
            System.Console.WriteLine(string.Format("Loan {0}. Interest amount: {1:C}", loan2.Customer.Name, loan2.CalculateInterestAmount(24)));

            Account deposit1 = new Deposit(pesho, 13M);
            Account deposit2 = new Deposit(firmataNaPesho, 13M);

            deposit1.DepositMoney(15M);
            deposit2.DepositMoney(2000M);

            System.Console.WriteLine(string.Format(
                                         "Deposit {0}. Interest amount: {1:C}", deposit1.Customer.Name, deposit1.CalculateInterestAmount(24)));
            System.Console.WriteLine(string.Format(
                                         "Deposit {0}. Interest amount: {1:C}", deposit2.Customer.Name, deposit2.CalculateInterestAmount(24)));


            Account mortage1 = new Mortgage(pesho, 10.2M);
            Account mortage2 = new Mortgage(firmataNaPesho, 10.2M);

            mortage1.DepositMoney(200M);
            mortage2.DepositMoney(200M);

            System.Console.WriteLine(string.Format(
                                         "Mortage {0}. Interest amount: {1:C}", mortage1.Customer.Name, mortage1.CalculateInterestAmount(24)));
            System.Console.WriteLine(string.Format(
                                         "Mortage {0}. Interest amount: {1:C}", mortage2.Customer.Name, mortage2.CalculateInterestAmount(24)));
        }
Пример #5
0
        // 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.


        static void Main(string[] args)
        {
            //====== Loan Acc - Individual - Interest ======
            Individuals az = new Individuals("Stanislav", "Ivanov");
            Loan        nz = new Loan(az, 50000, 5, 12);

            Console.WriteLine("Interest amount is {0}", nz.CalculateInterestAmount());
            Console.WriteLine("Current balance is {0}", nz.Balance);
            //====== Loan Acc - No Interest ======
            //Individuals az = new Individuals("Stanislav", "Ivanov");
            //Loan nz = new Loan(az, 50000, 5, 3);
            //Console.WriteLine(nz.CalculateInterestAmount());

            //====== Loan Acc - Company - Interest ======
            //Companies clubABC = new Companies("Stanislav", "Ivanov", "Club ABC");
            //Loan nz = new Loan(clubABC, 100000, 5, 12);
            //Console.WriteLine(nz.CalculateInterestAmount());
            //====== Loan Acc - Company - No Interest ======
            //Companies clubABC = new Companies("Stanislav", "Ivanov", "Club ABC");
            //Loan nz = new Loan(clubABC, 100000, 5, 2);
            //Console.WriteLine(nz.CalculateInterestAmount());

            //====== Mortgage Acc - Individual - Interrest ======
            //Individuals steve = new Individuals("Steve", "Jobs");
            //Mortgage dz = new Mortgage(steve, 1000000, 5, 12);
            //Console.WriteLine(dz.CalculateInterestAmount());
            //====== Mortgage Acc - Individual - No Interrest ======
            //Individuals steve = new Individuals("Steve", "Jobs");
            //Mortgage dz = new Mortgage(steve, 1000000, 5, 6);
            //Console.WriteLine("Your amount is: {0}", dz.CalculateInterestAmount());
            //dz.DepositMoney(5000);
            //Console.WriteLine("Money in the bank {0}", dz.Balance);

            //====== Mortgage Acc - Company - Interrest ======
            //Companies apple = new Companies("Steve", "Jobs", "Apple");
            //Mortgage dz = new Mortgage(apple, 1000000000, 10, 36);
            //Console.WriteLine("Your interest amount is {0}", dz.CalculateInterestAmount());
            //====== Mortgage Acc - Company - No Interrest ======
            //Companies apple = new Companies("Steve", "Jobs", "Apple");
            //Mortgage dz = new Mortgage(apple, 1000000000, 10, 5);
            //Console.WriteLine("Your interest amount is {0}", dz.CalculateInterestAmount());
            //dz.DepositMoney(300);
            //Console.WriteLine("Apple balance is {0}", dz.Balance);

            //====== Deposit Acc - Individual - Interrest ======
            //Individuals bill = new Individuals("Bill", "Gates");
            //Deposit rich = new Deposit(bill, 1000000000, 11, 24);
            //Console.WriteLine("Mr. Gates amount {0}", rich.CalculateInterestAmount());
            //rich.DepositMoney(1001);
            //Console.WriteLine("Your account balance is {0}", rich.Balance);
            //rich.DrawMoney(1);
            //Console.WriteLine("Money drawed. Your current account balance is {0}", (rich.Balance));
            //====== Deposit Acc - Individual - No Interrest ======
            //Individuals bill = new Individuals("Bill", "Gates");
            //Deposit notSoRich = new Deposit(bill, 950, 11, 4);
            //Console.WriteLine("Amount in account {0}", notSoRich.CalculateInterestAmount());
            //notSoRich.DepositMoney(1001);
            //Console.WriteLine("Your account balance is {0}", notSoRich.Balance);
            //notSoRich.DrawMoney(501);
            //Console.WriteLine("Money drawed. Your current account balance is {0}", (notSoRich.Balance));

            //====== Deposit Acc - Company - Interrest ======
            //Companies microsoft = new Companies("Bill", "Gates", "Microsoft");
            //Deposit rich = new Deposit(microsoft, 5000000, 5, 12);
            //Console.WriteLine("Your amount is {0}", rich.CalculateInterestAmount());
            //rich.DepositMoney(500);
            //Console.WriteLine("Deposit successful. Current balance is {0}", rich.Balance);
            //decimal drawedMoney = rich.DrawMoney(1500);
            //Console.WriteLine("You draw successful {0}. Current balance is {1}", drawedMoney, rich.Balance);
            //====== Deposit Acc - Company - No Interrest ======
            //Companies microsoft = new Companies("Bill", "Gates", "Microsoft");
            //Deposit notSoRich = new Deposit(microsoft, 500, 5, 6);
            //Console.WriteLine("Your amount is {0}", notSoRich.CalculateInterestAmount());
            //notSoRich.DepositMoney(500);
            //Console.WriteLine("Deposit successful. Current balance is {0}", notSoRich.Balance);
            //decimal drawedMoney = notSoRich.DrawMoney(100);
            ////Throw error if drawed money are more from account balance.
            ////decimal drawedMoney = notSoRich.DrawMoney(1500);
            //Console.WriteLine("You draw successful {0}. Current balance is {1}", drawedMoney, notSoRich.Balance);
        }