• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

lame objects question

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Keenan Staffieri
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic