Make sure you've got enough ends in there. The code you've provided is missing one at the bottom of it to close off the class (that applies to each of the four lots of code you provided).
In future, try telling us what the problem actually is, rather than saying it's an "error". We figured that part out already. There will always be some kind of message that pops up telling you something's gone wrong, and the trick is to read it and tell us what it said.
What do you mean, patronising?