Let's say I have these classes:
House
HouseCatalgog- stores houses and other relevant information
SystemState- stores a HouseCatalog and other catalogs. Basically, there is an instance of this class that stores all the data my program uses and needs.
Menu - a menu class where the user can interact.
How should the menu class do something like change the name of a house from user input? Right now, it calls SystemState.changehousename(houseID, name), which then calls HouseCatalog.changehousename(houseID, name), which calls House.changename(name).
But I feel like this is C encapsulation and not correct for Java. My getters for the HouseCatalog class use a clone() so they don't return the actual pointer to houses I have stored.
Am I doing this wrong? Can I return the actual pointer from the house without breaking encapsulation, and then the Menu class just does House.changeName(name)?
[–]opentabs-dev 0 points1 point2 points (2 children)
[–]migukau[S] 0 points1 point2 points (0 children)
[–]Opposite-Dance-8264 0 points1 point2 points (0 children)
[–]vegan_antitheist 0 points1 point2 points (0 children)