-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathItem.cpp
More file actions
69 lines (58 loc) · 1.47 KB
/
Item.cpp
File metadata and controls
69 lines (58 loc) · 1.47 KB
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
//
// Created by CalPC on 11/27/2018.
//
#include "Item.h"
#include <string>
#include <vector>
#include <iostream>
using namespace std;
Item::Item() {
this->names = {"basic"};
this->description = "Basic";
this->use = "basics";
this->usePhrases = {"use"};
}
Item::Item(vector<string> names, string description, string use, vector<string> usePhrases) {
this->names = names;
this->description = description;
this->use = use;
this->usePhrases = usePhrases;
addTheToNames(names);
}
Item::Item(vector<string> names, string description, string use, vector<string> usePhrases, int weight) {
this->names = names;
this->description = description;
this->use = use;
this->usePhrases = usePhrases;
this->weight = weight;
addTheToNames(names);
}
void Item::addTheToNames(vector<string> names){
for (unsigned int i = 0; i < names.size(); i++) {
this->names.push_back("the " + names.at(i));
}
}
bool Item::hasName(string name) {
for (unsigned int i = 0; i < names.size(); i++) {
if (names.at(i) == name) return true;
}
return false;
}
string Item::getName() {
return names.at(0);
}
string Item::getDescription() {
return description;
}
string Item::getUse() {
return use;
}
bool Item::hasUsePhrase(string phrase) {
for (unsigned int i = 0; i < usePhrases.size(); i++) {
if (usePhrases.at(i) == phrase) return true;
}
return false;
}
void Item::useItem() {
cout << use << endl;
}