-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclothing.cpp
executable file
·58 lines (50 loc) · 1.41 KB
/
clothing.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
#include "product.h"
#include "util.h"
#include <vector>
#include <string>
#include <set>
#include <sstream>
#include <iomanip>
#include "clothing.h"
using namespace std;
Clothing::Clothing(const string category, const string name, double price, int qty, string size, string brand)
: Product(category, name, price, qty)
{
size_ = size;
brand_ = brand;
}
Clothing::~Clothing(){
}
/**
* Returns the appropriate keywords that this product should be associated with
*/
set<string> Clothing::keywords() const{
set<string> returnThis = parseStringToWords(name_);
set<string> brand = parseStringToWords(brand_);
returnThis.insert(brand.begin(), brand.end());
return returnThis;
}
/**
* Allows for a more detailed search beyond simple keywords
*/
bool Clothing::isMatch(vector<string>& searchTerms) const{
return false;
}
/**
* Returns a string to display the product info for hits of the search
*/
string Clothing::displayString() const{
stringstream ss;
ss.precision(2);
ss << name_ << "\nSize: " << size_ + " Brand: " << brand_ + "\n";
ss << showpoint << fixed << price_ << " ";
ss << qty_ << " left.\nRating: ";
ss << getAvgRating();
return ss.str();
}
/**
* Outputs the product info in the database format
*/
void Clothing::dump(ostream& os) const{
os << category_ << "\n" << name_ << "\n" << price_ << "\n" << qty_ << "\n" << size_ << "\n" << brand_ << endl;
}