i suppose i'm asking best practice is. take example:
public abstract class gameobject { protected vector2 position; protected gameobject(vector2 position) { this.position = position; } protected vector2 getposition() { ... } protected void setposition(vector2 position) { ... } ... }
if have gameobject
abstract class player
extends, should setting of fields (e.g. speed, position) , methods in gameobject
protected?
what's nice way of doing this?
in order comply data encapsulation, practice keep fields private/protected , methods public.
Comments
Post a Comment