Results 21 to 23 of 23
Thread: OO Class Theory Question
- 04-20-2011, 05:44 AM #21
My inventory is a set length of 20 slots, and will be the only way a hero can carry items. This will not contain very super advanced awesome fun things like you'd find in WoW, I'm just looking for expanding my knowledge through practice.
That being said, does your statement still stand?
- Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
- +Rep people for helpful posts.
- 04-20-2011, 01:43 PM #22
If you have an inventory of 20 items, each one is going to be a separate instance of some class (so if you've got 20 daggers, you've got 20 instances of the Dagger class).
If you're displaying them on screen, presumably you have some way to translate from an index to a location on the screen. That means you should have some way to translate from a location on the screen to an index. Alternatively, you presumably have a reference to the instance you're displaying, so deleting it from the List should be pretty easy.
As we've seen here, there isn't one go-to method for using good OO design. Each person is going to have a slightly different take. Do whatever fits in your head the best, and go from there. Chances are, no matter what you write, you're going to come back to it in a year and say "what was I thinking when I did that??" anyway. So I wouldn't recommend you spend a ton of time on the design portion. It's good to know, but it's bad to spend too much time hammering square pegs into round holes. If it fits a certain way in your head, and it works, then that's the design you should use.
That's just my two cents though.
Last edited by KevinWorkman; 04-20-2011 at 01:46 PM.
- 04-20-2011, 02:16 PM #23
- By jigglywiggly in forum New To JavaReplies: 2Last Post: 01-01-2010, 01:04 PM
- By Supamagier in forum Advanced JavaReplies: 19Last Post: 05-12-2009, 05:11 PM
- By low224 in forum New To JavaReplies: 2Last Post: 01-01-2009, 05:02 AM
- By kirly in forum New To JavaReplies: 3Last Post: 11-11-2008, 06:47 AM
- By kavithas in forum New To JavaReplies: 4Last Post: 11-16-2007, 10:12 AM