-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbook.cpp
39 lines (33 loc) · 878 Bytes
/
book.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
#include "book.h"
#include "util.h"
#include <iostream>
#include <fstream>
#include <set>
#include <string>
using namespace std;
Book::Book(const string category, const string name,
double price, int qty, const string isbn,
const string author) :
Product(category, name, price, qty),
isbn_(isbn),
author_(author){}
Book::~Book(){
}
set<string> Book::keywords() const{
set<string> keyw_total;
set<string> keyw1 = parseStringToWords(name_);
set<string> keyw2 = parseStringToWords(author_);
keyw_total = setUnion(keyw1, keyw2);
keyw_total.insert(isbn_);
return keyw_total;
}
string Book::displayString() const{
string price = to_string(price_);
string qty = to_string(qty_);
return "Name: " + name_ + "\n" + "Quantity left: " +
qty + "\n" + "price: $" + price;
}
void Book::dump(ostream& os) const{
Product::dump(os);
os << isbn_ << "\n" << author_<<endl;
}