An exercise in using OOP techniques in JavaScript