You have written nice code, but now you have to start the debugging process of your code. Read this
Debugger tutorial to learn some information how to do it.
tips:
- write some test code, so you start with a clear scenario
- make some output and remove it later
- make output, when some error case may occur
good luck, you are on the right track ;-)