-
Notifications
You must be signed in to change notification settings - Fork 0
/
Book.cpp
executable file
·72 lines (56 loc) · 1.43 KB
/
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
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
//
// Created by nikang on 12/22/16.
//
#include "Book.h"
Book::Book(const string &name, Writer *writer) : name(name), writer(writer) {
this->book_id = Library::Id_generator();
writer->add_book(this);
this->is_availble = true;
}
void Book::remove() {
this->is_availble = false;
}
const string &Book::getName() const {
return name;
}
void Book::show_writer() {
cout << "the name is : " << this->name;
cout << " >>>->>> and the writer name is : " << this->writer->getName() << endl;
}
void Book::who_borrowed() {
if (!this->is_availble) {
cout << "this book is not available" << endl;
return;
}
if (this->is_issued) {
cout << "borrower name is : " << this->transactions.back()->getMember()->getName() << endl;
return;
}
cout << "not issued" << endl;
return;
}
long Book::getBook_id() const {
return book_id;
}
Writer *Book::getWriter() const {
return writer;
}
bool Book::isIs_issued() const {
return is_issued;
}
bool Book::isIs_availble() const {
return is_availble;
}
const vector<Transaction *> & Book::getTransactions() const {
return transactions;
}
void Book::borrowed(Transaction *transaction) {
this->is_issued = true;
this->transactions.push_back(transaction);
}
void Book::returned() {
this->is_issued = false;
}
Transaction *Book::last_transaction() {
return this->transactions[this->transactions.size() - 1];
}