-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmap.cc
288 lines (239 loc) · 7.83 KB
/
map.cc
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
/**
* @class Map
* @author Stephen M. Reaves
* @file map.cc
* @date Sep 16, 2018
* @brief This class stores clothes in Maps
*/
#include "map.h"
using namespace std;
/**
* Default Constructor
*/
Map::Map() {}
/**
* Deconstructor
*/
Map::~Map() {}
/**
* Init
* @returns Boolean representing success (or failure) of initialization
*/
bool Map::Init() {
isInit_ = false;
// Do stuff here
isInit_ = true;
return isInit_;
}
/**
* Die
*/
void Map::Die() {}
/**
* InsertShirt
* @param name Name of the shirt
* @brief Inserts 'Shirt' into 'shirt_map_'
*
* @param primary_color Primary color of the shirt
* @param secondary_color Secondary color of the shirt
* @param tertiary_color Third color of the shirt
* @param pattern Color pattern of the shirt
* @param sleeve_length Length of the sleeve, not in not in number, 'short,
* long', etc
* @param collar Type of collar
*
* @returns true if insert was succesful, false otherwise
*/
bool Map::InsertShirt(string name, string primary_color, string secondary_color,
string tertiary_color, string pattern,
string sleeve_length, string collar) {
int status = false;
int id = -1;
do {
id = this->AssignID("shirt");
} while (id == -1); // This should never happen
Shirt shirt(id, name, primary_color, secondary_color, tertiary_color, pattern,
sleeve_length, collar);
shirt_map_.insert(pair<int, Shirt>(id, shirt));
status = true;
return status;
}
/**
* InsertPants
* @brief Inserts 'Pants' into 'pants_map_'
*
* @param name Name of the pants
* @param primary_color Primary color of the pants
* @param secondary_color Secondary color of the pants
* @param tertiary_color Third color of the pants
* @param material Material of the pants, 'denim', 'chino' etc.
* @param length Length of pants, not in number, 'shorts', 'long', etc.
* @param cut Cut of pants
*
* @returns true if insert was successful, false otherwise
*/
bool Map::InsertPants(string name, string primary_color, string secondary_color,
string tertiary_color, string material, string length,
string cut) {
int status = false;
int id = -1;
do {
id = this->AssignID("pants");
} while (id == -1); // This should never happen
Pants pants(id, name, primary_color, secondary_color, tertiary_color,
material, length, cut);
pants_map_.insert(pair<int, Pants>(id, pants));
status = true;
return status;
}
/**
* InsertSocks
* @brief Inserts 'Socks' into 'socks_map_'
*
* @param name Name of the socks
* @param primary_color Primary color of the socks
* @param secondary_color Secondary color of the socks
* @param tertiary_color Third color of the socks
* @param pattern Pattern of the socks
*
* @returns true if insert was successful, false otherwise
*/
bool Map::InsertSocks(string name, string primary_color, string secondary_color,
string tertiary_color, string pattern) {
int status = false;
int id = -1;
do {
id = this->AssignID("socks");
} while (id == -1); // This should never happen
Socks socks(id, name, primary_color, secondary_color, tertiary_color,
pattern);
socks_map_.insert(pair<int, Socks>(id, socks));
status = true;
return status;
}
/**
* InsertShoes
* @brief Inserts 'Shoes' into 'shoes_map_'
*
* @param name Name of the shoes
* @param primary_color Primary color of the shoes
* @param secondary_color Secondary color of the shoes
* @param tertiary_color Third color of the shoes
* @param material Material of the shoes, 'leather', 'suede', etc.
* @param style Style of the shoes
*
* @returns true if insert was successful, false otherwise
*/
bool Map::InsertShoes(string name, string primary_color, string secondary_color,
string tertiary_color, string material, string style) {
int status = false;
int id = -1;
do {
id = this->AssignID("shoes");
} while (id == -1); // This should never happen
Shoes shoes(id, name, primary_color, secondary_color, tertiary_color,
material, style);
shoes_map_.insert(pair<int, Shoes>(id, shoes));
status = !status;
return status;
}
/**
* InsertBelt
* @brief Inserts 'Belt' into 'belt_map_'
*
* @param name Name of the belt
* @param primary_color Primary color of the belt
* @param secondary_color Secondary color of the belt
* @param tertiary_color Third color of the belt
* @param material Material of the belt, 'leather', 'tweed', etc.
* @param pattern Pattern of the belt
*
* @returns true if insert was successful, false otherwise
*/
bool Map::InsertBelt(string name, string primary_color, string secondary_color,
string tertiary_color, string material, string pattern) {
int status = false;
int id = -1;
do {
id = this->AssignID("belt");
} while (id == -1); // if this happens i will dye
Belt belt(id, name, primary_color, secondary_color, tertiary_color, material,
pattern);
belt_map_.insert(pair<int, Belt>(id, belt));
status = true;
return status;
}
/**
* GetClosetName
* @returns Closet Name
*/
string Map::GetClosetName() { return this->closet_name_; }
/**
* ToString
* @returns 'string' representing the closet
*/
string Map::ToString() const {
string s = "";
s += "\n*********** Shirts ************\n";
for (map<int, Shirt>::const_iterator iter = shirt_map_.cbegin();
iter != shirt_map_.cend(); ++iter) {
s += iter->second.ToString();
}
s += "\n********** Pants **************\n";
for (map<int, Pants>::const_iterator iter = pants_map_.cbegin();
iter != pants_map_.cend(); ++iter) {
s += iter->second.ToString();
}
s += "\n********** Socks **************\n";
for (map<int, Socks>::const_iterator iter = socks_map_.cbegin();
iter != socks_map_.cend(); ++iter) {
s += iter->second.ToString();
}
s += "\n********** Shoes **************\n";
for (map<int, Shoes>::const_iterator iter = shoes_map_.cbegin();
iter != shoes_map_.cend(); ++iter) {
s += iter->second.ToString();
}
s += "\n********** Belts **************\n";
for (map<int, Belt>::const_iterator iter = belt_map_.cbegin();
iter != belt_map_.cend(); ++iter) {
s += iter->second.ToString();
}
return s;
}
/**
* AssignID
* @param type A string dictating the type of clothing to check.
* @return An integer corrosponding to the next available ID for the given
* type, or -1 for an error.
* @brief Assigns unique ID to clothes
* @detail This function assigns the next available ID number for a given
* type. The last two numbers represent the number of the given type,
* while the other numbers represent the type. For Example, if there
* are currently 4 shirts, then the next shirt will have the ID of 105.
* The 100 represents shirts, while the 05 means it is the fifth shirt.
* This allows for 99 items of a given type and (2^29)-1 types???
* @note So far the types are hard coded in. Meaning you can only
* create clothes that are either shirts, pants, belts, socks, or shoes.
* There is currently no way to dynamically add types. Underwear types
* were intentionally left out to test the best way to dynamically add
* new types.
*/
int Map::AssignID(string type) {
int id = -1; // dummy id number
// switch (type){
// case "shirt":
///< @todo Use Switch-case for Closet::AssignID
if (type == "shirt") {
id = 100 + static_cast<int>(shirt_map_.size());
} else if (type == "pants") {
id = 200 + static_cast<int>(pants_map_.size());
} else if (type == "belt") {
id = 300 + static_cast<int>(belt_map_.size());
} else if (type == "socks") {
id = 400 + static_cast<int>(socks_map_.size());
} else if (type == "shoes") {
id = 500 + static_cast<int>(shoes_map_.size());
}
return id;
}