-
Notifications
You must be signed in to change notification settings - Fork 0
/
Store.cpp
58 lines (47 loc) · 921 Bytes
/
Store.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "Store.h"
#include "ItemWeapon.h"
#include "ItemArmor.h"
CStore::CStore()
{
}
CStore::~CStore()
{
Safe_Delete_VecOrList(m_vecItem);
}
CItem * CStore::CreateItem(const string & strName, ITEM_TYPE eType, int iPrice, int iSell, const string & strDesc)
{
CItem* pItem = nullptr;
switch (eType)
{
case IT_WEAPON:
pItem = new CItemWeapon;
break;
case IT_ARMOR:
pItem = new CItemArmor;
break;
default:
break;
}
if (!pItem->Init())
{
SAFE_DELETE(pItem);
return NULL;
}
pItem->SetName(strName);
pItem->SetItemInfo(eType, iPrice, iSell, strDesc);
m_vecItem.push_back(pItem);
return pItem;
}
void CStore::OutputItemList()
{
for (size_t i = 0; i < m_vecItem.size(); ++i)
{
cout << i + 1 << ". ";
m_vecItem[i]->Render();
cout << endl;
}
}
void CStore::OutputTag(const string & StoreName)
{
cout << "======================" << StoreName << "======================" << endl;
}