This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
It makes me feel inferior to ask this, but I have a question about objects in classes. Well I am working with a canvas, and I decided that I want to make a seperate object to have contructors that keeps track of screenwidth ect.
like:
i constructed it in WorldGenerator (which contains my main class)
I can refer to the setting object anywhere i want in the world generator class. BUT i cant refer to the setting object in a different TileMap class, because it cant recognize symbol because i didnt construct the object in the TileMap class:
So i guess i pretty much messed up my design... i also tryed using things like static and public, but it feels "wrong" and, it doesnt work anyway. I even tryed to extend the WorldGenerator class, but it causes compile errors with the paramaters in the TileMap constructors. [ December 06, 2006: Message edited by: Keenan Staffieri ]
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35236
7
posted
0
The reference to ProgramSetting could either be another parameter of the TileMap constructor, or the TileMap class could have a "setProgramSetting(ProgramSetting)" setter that is invoked after a TileMap object is constructed.
but i never want to change the screenwidth ect, in tile map. i want to make it so i can use the 'setting' object in ANY class, but i guess my design is messed up since i am using the setting thingy in a class that shouldnt have to take screenwidth parameters in the constructor. any recommendations?
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35236
7
posted
0
You can also make the ProgramSetting object in TileMap public and static, so that any class can get access to it without needing to have a reference to it.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.