-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibrary.cpp
More file actions
85 lines (69 loc) · 2.67 KB
/
Copy pathLibrary.cpp
File metadata and controls
85 lines (69 loc) · 2.67 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
//---------------------------------------------------------------------------
// library.h
//---------------------------------------------------------------------------
// Library class acts as interface between data files and storage / functions
//
// Assumptions:
// -- correctly formatted input from file
// -- each book item is uniquely identified by its srting criteria
// -- each command is uniquely and correctly identified by command char
// Implementation:
// -- holds a book factory, command factory, patron container, and bookcase
// -- Library reads input from data files
//---------------------------------------------------------------------------
#include "Library.h"
//---------------------------------------------------------------------------
// constructor
Library::Library() {}
//---------------------------------------------------------------------------
// destructor
Library::~Library() {}
//---------------------------------------------------------------------------
// buildPatron
// data format --> ID# Last First
bool Library::buildPatrons(istream &inFile) {
return patContainer.insert(inFile);
}
//---------------------------------------------------------------------------
// runCommands
bool Library::performCommands(istream &inFile) {
return commManager.performCommands(inFile, this);
}
//---------------------------------------------------------------------------
// buildLibrary
bool Library::buildLibrary(istream &in) { return shelf.buildLibrary(in); }
//---------------------------------------------------------------------------
// displayItems
void Library::displayItems() const { shelf.display(); }
//---------------------------------------------------------------------------
// displayPatrons
void Library::displayPatrons() const { patContainer.display(); }
//---------------------------------------------------------------------------
// getPatron
bool Library::getPatron(int userID, Patron *&toReturn) {
bool success = false;
// valid ID retrieve patron from PatronContainer
if (userID > 0 && userID < 10000) {
Patron *patron = nullptr;
patContainer.retrieve(userID, patron);
if (patron != nullptr) {
toReturn = patron;
success = true;
}
}
return success;
}
//---------------------------------------------------------------------------
// getItem
bool Library::getItem(Item &target, Item *&toReturn) {
bool success = false;
// retrieve item from shelf
Item *retrieved;
// if successfully retrieved item
if (shelf.retrieve(target, retrieved)) {
// set referenced to item to found item
toReturn = retrieved;
success = true;
}
return success;
}