You may wish to consider an object oriented approach:
- Objects / Processing.org
- Using Objects - Happy Coding
- 8.1: What is Object-Oriented Programming (OOP)? - Processing Tutorial
Example:
It make take some time but the reward is well worth the effort.
:)