Transform code to OOP style

Hello, I've attempted to fix issue #10 here, to transform the code into OOP style. The tests pass, so I hope it's okay.