-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBook.cpp
More file actions
118 lines (104 loc) · 2.91 KB
/
Book.cpp
File metadata and controls
118 lines (104 loc) · 2.91 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include "Book.h"
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
using std::ostream;
using std::istream;
void Book::setAuthor(String author) { author_ = author; }
void Book::setName(String name) { name_ = name; }
void Book::setYear(unsigned short int year) { year_ = year; }
void Book::setDiscpline(String discipline) { discipline_ = discipline; }
void Book::setAmount(unsigned short int amount) { amount_ = amount; }
//=========================================================
String Book::getAuthor() const { return author_; }
String Book::getName() const { return name_; }
int Book::getYear() const { return year_; }
String Book::getDiscipline() const { return discipline_; }
int Book::getAmount() const { return amount_; }
//=========================================================
Book& Book::operator= (const Book& book)
{
author_ = book.author_;
name_ = book.name_;
year_ = book.year_;
discipline_ = book.discipline_;
amount_ = book.amount_;
return *this;
}
size_t Book::operator= (size_t amount)
{
return amount_;
}
//==========================================================
bool operator> (const Book& book1, const Book& book2)
{
return book1.amount_ > book2.amount_;
}
bool operator> (const Book& book1, const int amount)
{
return book1.amount_ > amount;
}
bool operator> (const int amount, const Book& book2)
{
return amount > book2.amount_;
}
//============================================================
bool operator< (const Book& book1, const Book& book2)
{
return book1.amount_ < book2.amount_;
}
bool operator< (const Book& book1, const int amount)
{
return book1.amount_ < amount;
}
bool operator< (const int amount, const Book& book2)
{
return amount < book2.amount_;
}
//============================================================
bool operator== (const Book& book1, const Book& book2)
{
return book1.amount_ == book2.amount_;
}
bool operator== (const Book& book1, const int amount)
{
return book1.amount_ == amount;
}
bool operator== (const int amount, const Book& book2)
{
return amount == book2.amount_;
}
//=============================================================
bool operator!= (const Book& book1, const Book& book2)
{
return !(book1.amount_ == book2.amount_);
}
bool operator!= (const Book& book1, const int amount)
{
return !(book1.amount_ == amount);
}
bool operator!= (const int amount, const Book& book2)
{
return !(amount == book2.amount_);
}
//===============================================================
ostream& operator<< (ostream& out, const Book& book)
{
out << "Author of the book is: " << book.author_ << endl;
out << "Name of the book is: " << book.name_ << endl;
out << "Year of publishing is: " << book.year_ << endl;
out << "Book discipline is: " << book.discipline_ << endl;
out << "Amount of books in library: " << book.amount_ << endl;
return out;
}
Book Book::operator++()
{
amount_++;
return *this;
}
Book Book::operator--()
{
amount_--;
return *this;
}