Object-Oriented Design in Procedural Environments
by Thomas E. Davis


Listing One
structure PersonStruct
    integer age
endstruct

function personSetAge( PersonStruct person, integer age ) returns integer
    if( age > 0 )
    begin
        person.age = age
        return 0
    end
    else
    begin
        return -1
    end
end function


Listing Two 
$$INCLUDE "Person.inc"

structure UserAccountStruct
    PersonStruct person
    string password
endstruct

function userAccountSetAge( UserAccountStruct account, integer age )
    integer status
    status = personSetAge( account.person, age )
    return status
end function

function userAccountCheckPassword(UserAccountStruct account,string password)
    if( account.password = password )
    begin
        return 0
    end
    else
    begin
        return -1
    end
end function










4


