Need some help with A Inventory system using OOP

Started by
28 comments, last by Alberth 8 years ago

Solved

Advertisement

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

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)

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?

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.

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


the task is

Just to be clear, is this homework?

Hello to all my stalkers.

^^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

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

Start with one type, for example.

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,

This topic is closed to new replies.

Advertisement