-
Notifications
You must be signed in to change notification settings - Fork 0
/
room.cpp
103 lines (84 loc) · 2.04 KB
/
room.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*This will define the member funtions and constructors of the Room class*/
//preprocessor
#include "room.h"
//constructor definitions
Room::Room() {
xcoord = 0;
ycoord = 0;
name = "";
desc = "This is a room with no description.";
}
Room::Room(int xcoord0, int ycoord0) {
xcoord = xcoord0;
ycoord = ycoord0;
name = "";
desc = "This is a room with no description.";
}
Room::Room(int xcoord0, int ycoord0, string name0) {
xcoord = xcoord0;
ycoord = ycoord0;
name = name0;
desc = "This is a room with no description.";
}
Room::Room(int xcoord0, int ycoord0, string name0, string desc0) {
xcoord = xcoord0;
ycoord = ycoord0;
name = name0;
desc = desc0;
}
Room::Room(int xcoord0, int ycoord0, string name0, string desc0, Item item) {
xcoord = xcoord0;
ycoord = ycoord0;
name = name0;
desc = desc0;
loot.push_back(item);
}
//member function definitions
int Room::get_xcoord() {
return xcoord;
}
int Room::get_ycoord() {
return ycoord;
}
string Room::get_name() {
return name;
}
string Room::get_desc() {
return desc;
}
void Room::set_xcoord(int xcoord0) {
xcoord = xcoord0;
}
void Room::set_ycoord(int ycoord0) {
ycoord = ycoord0;
}
void Room::set_name(string name0) {
name = name0;
}
void Room::set_desc(string desc0) {
desc = desc0;
}
void Room::list_loot() {
cout << "\t\t" << "< Items in this room >" << "\n";
for (int i = 0; (unsigned)i < loot.size(); i++) {
cout << "\t\t" << "<" << i + 1 << ">\t" << loot[i].get_name() << "\n";
}
cout << "\n";
}
vector<Item>* Room::get_loot() {
return &loot;
}
int Room::get_loot_size() {
return (int)loot.size();
}
void Room::add_item(Item item0) {
loot.push_back(item0);
}
void Room::remove_item(Item item0) {
for (int i = 0; (unsigned)i < loot.size(); i++) {
if (loot[i] == item0) {
loot.erase(loot.begin() + i);
break;
}
}
}