-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitems.h
69 lines (44 loc) · 1.13 KB
/
items.h
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
#ifndef items_and_methos
#define items_and_methos
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <typeinfo>
#include <regex>
using namespace std;
// ITEM AND METHODS
class item{
public:
string name;
float value;
float weight;
float profit;
item(string,float,float,float);
void displayItem();
};
item::item(string name,float value,float weight,float profit){
this->name=name;
this->weight=weight;
this->value=value;
this->profit=profit;
}
void item::displayItem(){
cout<<this->name<<"(Value: "<<this->value<<", Weight: "<<this->weight<<", Profit: "<<this->profit<<")"<<endl;
}
void displayContainer(vector<item> Container){
cout<<"Name | Val | Wt | Prof";
for(int c=0;c<Container.size();c++){
cout<<Container[c].name<<"|"<<Container[c].value<<"|"<<Container[c].weight<<"|"<<Container[c].profit<<endl;
}
}
bool operator<(const item& a, const item& b){
return a.profit<b.profit;
}
bool operator>(const item& a, const item& b){
return a.profit>b.profit;
}
bool operator==(const item& a, const item& b){
return a.profit==b.profit;
}
#endif