Skip to content
Snippets Groups Projects
Commit 2448e489 authored by Ian Prins's avatar Ian Prins
Browse files

Implement itemzone.h

parent 6293ff2f
No related branches found
No related tags found
No related merge requests found
......@@ -6,9 +6,11 @@
class ItemZone {
public:
ItemZone();
Item operator[](int);
bool remove(Item);
void add(Item);
bool remove(Item&);
void add(Item&);
bool contains(Item&);
private:
std::vector<Item> contents;
};
......
#include "include/itemzone.h"
#include <vector>
#include <algorithm>
using namespace std;
ItemZone::ItemZone()
: contents() {
}
Item ItemZone::operator[](int i) {
return contents[i];
}
bool ItemZone::remove(Item& item) {
auto it = find(begin(contents), end(contents), item);
if (it != end(contents)) {
contents.erase(it);
return true;
}
return false;
}
void ItemZone::add(Item& item) {
contents.push_back(item);
}
bool ItemZone::contains(Item& item) {
return find(begin(contents), end(contents), item) != end(contents);
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment