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