-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisplayLibrary.cpp
More file actions
76 lines (70 loc) · 1.97 KB
/
Copy pathdisplayLibrary.cpp
File metadata and controls
76 lines (70 loc) · 1.97 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
/**
* @file displayLibrary.h
* @author Alex Lambert
*
* Description:
* - Displays all books in the library, sorted
*
* Assumptions/Implementation:
* - Inherits from Command interface
* - Doesn't need to use the patronDatabase
*/
#include "displayLibrary.h"
using namespace std;
//---------------------------------------------------------------------------
/** DisplayLibrary()
* Default Constructor
*
* Constructs a base instance of the display library command. This
* instance must not be executed.
* @param bookDB is the BookDatabase to be displayed
* @pre None
* @post DisplayLibrary command object exists for bookDB
*/
DisplayLibrary::DisplayLibrary(BookDatabase* bookDB)
{
this->bookDB = bookDB;
}
//---------------------------------------------------------------------------
/** ~DisplayLibrary()
* Default Destructor
*
* Destroys this command
* @pre None
* @post Deallocates memory used by this command.
*/
DisplayLibrary::~DisplayLibrary()
{
bookDB = nullptr;
}
//---------------------------------------------------------------------------
/** execute()
* Execute DisplayLibrary Command
*
* Prints all books in library in sorted order
* @pre None
* @post None. Library is unchanged
*/
void DisplayLibrary::execute()
{
cout.setf(ios::left, ios::adjustfield);
bookDB->displayAll();
}
//---------------------------------------------------------------------------
/** create()
* Create DisplayLibrary Command (factory)
*
* Creates a DisplayLibrary command that can be executed
* @param parameters is a reference to the ifstream, starting immediately
* after the command code
* @pre None
* @post No changes, just returns the new command. Parameters will read up
* until and including the end-of-line character
* @return returns the new executable command, or nullptr if the
* parameters were invalid
*/
LibraryCommand* DisplayLibrary::create(stringstream& parameters) const
{
parameters.get();
return new DisplayLibrary(bookDB);
}