code refactoring of Ship class