-
Notifications
You must be signed in to change notification settings - Fork 0
/
book.cpp
58 lines (49 loc) · 1.45 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
#include "book.h"
//----------------------------------------------------------------------------
//constructor
Book::Book() {
}
//----------------------------------------------------------------------------
//deconstructor
Book::~Book() {
}
//----------------------------------------------------------------------------
//getType
//returns the product type character
char Book::getType() const {
return bookType;
}
//----------------------------------------------------------------------------
//getInstock
//returns the number of instock books
int Book::getInstock() const {
return instock;
}
//----------------------------------------------------------------------------
//getCheckedOut
//returns the number of checked out copies
int Book::getCheckedOut() const {
return checkedOut;
}
//----------------------------------------------------------------------------
//checkout
//used to decrease in stock books and increase checked out books. Prints
//error if does not have any books in stock
bool Book::checkout() {
if (instock > 0) { //check for instock
instock--;
checkedOut++;
return true;
}
else { //not in stock
return false;
}
}
//----------------------------------------------------------------------------
//checkin
//used to increase instock and decrease checked out books.
bool Book::checkin() {
instock++;
checkedOut--;
return true;
}