Procedural vs Object-Oriented


A Simple OO Class

public class SomeClass
{
    // Instance variable(s)
    private int[]  theData;

    // Constructor(s)
    public SomeClass()
    {
        // constructor code goes here
    }
    .
    .
    .

    /** Search for given value; return index. */
    public int search(int searchValue)
    {
        for ( int i = 0; i < theData.length; i++ )
        {
            if ( theData[i] == searchValue )
            {
                return i;
            }
        }
        return -1;
    }
    .
    .
    .
}

Alyce Brady, Kalamazoo College