Jump to content
  • Advertisement
Sign in to follow this  
SCB

Need some help with A Inventory system using OOP

This topic is 841 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

Advertisement

What is the problem with your current implementation? It seems you believe there is a better way, what do you have in mind?

Share this post


Link to post
Share on other sites
So at the minute, I have 4 separate menu options to add a character, weapon, object and spell

Nothing currently has values other than me entering their names

That's the problem, giving the things values using oop (which I'm really new at)

Share this post


Link to post
Share on other sites

I don't really understand the problem yet.

 

The menu options do what?

 

I would make them open a window with a few fields that you can fill, and an OK button.

 

Is that what you aim at? Can you show us what you mean?

Share this post


Link to post
Share on other sites

It sounds like you're trying to implement a configuration parser and writer, and you're having issues making this work well with your object types?

You would typically add config serialization and deserialization functions to your object classes, or maybe even a constructor that operates on a pre-parsed config.

If you're asking for advice on how to write a config parser and writer, that's really not a place where OOP applies - by their nature configurations work on plain data. If you're having issues wrapping your head around it, there are lots of open source configuration parsers out there.

I will make one note, though: if you're implementing a way to store item data for a game, you're better off using a binary format. A text-based file is slower to load, slower to save, and takes significantly more disk space than a binary one. Especially since it looks like you're already working on a tool for the purpose of modifying these, I'd just take this opportunity to go with a binary format.

Share this post


Link to post
Share on other sites

ok, I'll start again, the task is

 

"Using an object orientated approach, write a program that add's , stores, deletes and can edit items from a players bank of characters, weapons, objects and spells"

 

So, essentially what I'm trying to do is create 4 arrays (character, weapon, object, spell) and then the menu was giving a choice of adding one of those to its respective array.

 

What's I'm struggling with is using pointers to do this, I've only just started using OOP and do understand using classes, constructors and decontructors fine

Share this post


Link to post
Share on other sites

^^Yes, which is why I'm asking for help, not code, I need to understand what I'm doing rather than just be given an answer

Share this post


Link to post
Share on other sites

It looks like setting up the OO solution from scratch is too much, try to reduce the problem.

Start with one type, for example.

 

I see what you mean, I'm focusing on just the character for now, it's be similar for the rest I assume anyway, 

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!