MrBones 0 Newbie Poster

I'm making a program that simulates logic gates.
However, I'm running into a few problems.
A variable called gatespresent knows how many gates have been placed in the form. Each instance of a logic gate (user controls for either OR AND or NOT) also has a variable telling it which order it was put out in (this starts at 0 btw)

However, in order for each gate to know what the previous gate was, and what it therefore output, it has to work out who has gatenumber - 1.
I decided the best way to do this would be to have an array of objects called gatesout[5], where the index order in which the gates were placed. ie first objects = gatesout[0], etc.
But this variable only has the standard methods of an object, not my logic gates.

Basically, I want some way of looking at the object before in the array and accessing the method there that tells me what that gate will output.

Sorry, if this doesn't make too much sense.