1. Open an IDE
2. Start typing

What exactly are you expecting people to post? This is not simple code and apparently it is your job to write it not ours. If you have written code then post it...