Jump to content
  • Advertisement
Sign in to follow this  
jbadams

returning from a loading class (java)

This topic is 4986 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm programming a fairly simple game in Java with a friend of mine, and we've been trying to figure out how exactly to load in data stored in text files. We've got shipModule and weaponModule classes, and the data for each of these is stored in a seperate text file, but both of the textfiles share the same format. Our first thought was just to have a loading function in each class that loads the data, and this would be simple enough to do. However, we thought it would be better to create a loading class, which either module could use to load the data it needs. There will be a few other item classes which would also be able to make use of this. We can't quite figure out how to actually return the loaded data to the appropriate class however. Do we return an array containing the data, use public variables (probably not a good idea), or what? So can anyone give some tips on how this could best be accomplished? Any appropriate links, advice or code examples would be most appreciated. Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Return an object (possibly array) containing the data. Ideally the return value should have some kind of "structure" which reflects the file format. It's OK to have public data within this thing, since its only purpose in life is to be consumed by a Ship or Weapon object constructor (or class static initializer? :s )

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!