Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes lame objects question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "lame objects question" Watch "lame objects question" New topic
Author

lame objects question

Keenan Staffieri
Greenhorn

Joined: Jul 22, 2006
Posts: 23
Hi,

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: 42031
    
  64
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.


Ping & DNS - my free Android networking tools app
Keenan Staffieri
Greenhorn

Joined: Jul 22, 2006
Posts: 23
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: 42031
    
  64
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.
 
GeeCON Prague 2014
 
subject: lame objects question