I am designing a role playing game. In such games there is a character that has a level. I found out that the level itself is an object. It has values like experience, the knowledge of how moch experience is needed for a level-up, and methods like improve() or gainExperience(). So the character should have a level object. A game-object could have a fight-method. When the character wins a fight, he gains experience. The game object has access to the player object. But the problem now is: All fields should be private. So I would have to write a getter for getting the level object to increase the experience which looks like unesseccary code to me. Is it an accepted way to set the level-field of the character object public, and access it like that:
or is there a better way to access methods of fields that are also objects?
Edit My question is different from this one. While the quoted question is very general, mine refers to a concrete example, which limits the possibilities of answering, and makes an answer simpler and clearer