-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBook.cpp
More file actions
79 lines (49 loc) · 1.1 KB
/
Book.cpp
File metadata and controls
79 lines (49 loc) · 1.1 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
70
71
72
73
74
75
76
77
78
79
#include "Book.h"
#include "Header.h"
Book::Book() {
title = " ";
cost = 0.0;
count++;
}
Book::Book(const std::string& t, double c) {
title = t;
cost = c;
count++;
}
Book::~Book() {};
void Book::setTitle(const std::string& t) {
title = t;
}
void Book::setCost(double c) {
cost = c;
}
std::string Book::getTitle()const {
return title;
}
double Book::getCost()const {
return cost;
}
void Book::printBook()const {
std::cout << "Title is: " << title << std::endl;
std::cout << "The cost is: $" << cost << std::endl;
}
int Book::getCount() {
return count;
}
bool Book::operator >(const Book& book2)const {
if (cost > book2.cost)
return true;
else
return false;
}
bool Book::operator >(double price)const {
return cost > price;
}
double Book::operator +(const Book& book2)const {
return cost + book2.cost;
}
std::ostream& operator <<(std::ostream& stream, const Book& book) {
stream << "\nTitle is: " << book.title << std::endl;
stream << "The cost is: $" << book.cost << std::endl;
return stream;
}