I need to create an inventory system that can add delete and edit. For one player there can be as as many characters as the player wishes to create so for an example a player can have 5 different characters. I want the player to be able to run the program and choose add new character and then be able to type in the characters name and gender and then select the type of character which will have preset values for magical ability, strength, health and wealth. I then want the player to be able to edit the characters name, gender or type or delete that character.
so far this is what I have got and am completely stuck on where to go next.
#include "stdafx.h"
#include "ObjectArray.h"
ObjectArray::ObjectArray(void) :capacity(10), used(0)
{
a = new Character[capacity];
}
ObjectArray::~ObjectArray(void)
{
delete [] a; //as we have used a dynamic array we have
// to do this to return memory to the free store
}
void ObjectArray::addElement(Character element)
{
a[used] = element;
used++;
}
Character& ObjectArray::operator[](int index)
{
return a[index];
}
int ObjectArray::getUsed()
{
return used;
}
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
#include <string>
usingnamespace std;
class Character //a record holding all the data on one character
{
private:
string uniquename; //allows for a char called uniquename that can be up to 35 characters long
string sex; //allows for a char called sex that can be up to 6 characters long
string type; //allows for a char called type that can be up to 8 characters long
int magicalability; //holds the magicalability of the character
int strength; //holds the strength of the character
int health; //holds the health of the character
int wealth; //holds the wealth of the character
public:
Character(void);
Character(string, string, string, int, int, int, int);
~Character(void);
string getuniquename();
string getsex();
string gettype();
int getmagicalability();
int getstrength();
int gethealth();
int getwealth();
};
Objectarray.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#pragma once
#include "Character.h"
class ObjectArray
{
private:
Character *a; //used for an array of Person objects
int capacity;
int used;
public:
ObjectArray(void);
void addElement(Character element);
Character& operator[](int index);
int getUsed();
~ObjectArray(void);
};
Any help will be much appreciated as to how to move on.
I can add say for example a menu system asking what they would like to do but have no clue how to implement the edit, add and delete function? I know at present it displays what I have typed in but I know this part is no good if I want to allow the user to change the data.
Thanks