^
Why do I need to know if I've done anything wrong in the header, I know there are no algorithms, but that's what i USE to write the algorithms (which work, apparently),
I'm wondering if the struct is the best way to save the "Item" because I need something to save all of it's properties
and the struct and vector are doing it well.
(Compiles as a static library)
Mutators are so... (in pseudocode)
Code: Select all
unsigned end = CItem::items.size();
for(unsigned f=0;!CItem::items.empty();++f)
{
if(f<end)
{
if(CItem::items[f].name == Item_Name)
{
CItem::items[f].<property> = <value of property given to the function>;
break;
}
}
}
Accessors are so... (GetItemByName/Element follows the same code as above mostly, it just returns an ITEM)
Code: Select all
return CItem::GetItemByName(Item_Name).<property>;
And/or
Code: Select all
return CItem::GetItemByElement(Item_ID).<property>;
and example for use of this class is...
Code: Select all
#include "Items.h"
#include <iostream>
int main()
{
CItem *G_Item;
G_Item = new CItem;
G_Item->CreateItem("Sword of the unfrogotten");
G_Item->CreateItem("Misha the unforgotten");
std::string d ="Sword of the unfrogotten";
std::cout<<"Item: "<<G_Item->GetItemByElement(2).name.c_str()<<" \n";
G_Item->SetItemDescription(d,"It sucks like shit\n");
std::cout<<"Description: "<<G_Item->GetItemDescription(d).c_str();
G_Item->CreateItemFS("MOM","LOVELY",5.5f,500,400,30,NULL);
std::cout<<"\n\n\n\n"<<"New Item: "<<G_Item->GetItemDescription("MOM").c_str()<<std::endl;
system("PAUSE");
}