Added factory, base class and all subclasses + the logic to do the required calculation