-
Notifications
You must be signed in to change notification settings - Fork 0
/
libraryCommand.h
120 lines (103 loc) · 2.88 KB
/
libraryCommand.h
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
119
120
/** @file librarycommand.h
* @author Josh Helzerman
*
* Description:
* - Class that encapsulates a variety of LibraryCommands that the library
* manager can execute
*
* Implementation:
* - this is an abstract class and must be implemented in the child classes
* - this class is similar to an interface in Java
*
*/
#ifndef LIBRARYCOMMAND_H
#define LIBRARYCOMMAND_H
#include "patronDatabase.h"
#include <iostream>
class PatronDatabase;
class BookDatabase;
class Book;
using namespace std;
class LibraryCommand
{
public:
// -------------------------------------------------------------------------
/** LibraryCommand()
* Defaul Constructor
*
* Constructs a LibraryCommand object.
* @pre None.
* @post LibraryCommand object exists
*/
LibraryCommand();
// -------------------------------------------------------------------------
/** ~LibraryCommand()
* Destructor
*
* Deletes command from memory. It's empty, but apparently helps to delete
* @pre None.
* @post LibraryCommand instance is deleted
*/
virtual ~LibraryCommand();
// -------------------------------------------------------------------------
/** execute()
* Execute LibraryCommand
*
* Executes this LibraryCommand object. This is pure virtual and must be
* implemented in derived classes
* @pre TBD
* @post TBD
*/
virtual bool execute() = 0;
/** create()
* Create Library Command (factory)
*
* Create a library command of the appropriate type
* this function is pure virtual
* @pre None
* @post a new library command exists
*/
virtual LibraryCommand* create() const = 0;
/** initialize()
* initialize command with data
*
* Uses a string to put data into the command
* @pre string must be formatted properly
* @post the command now contains the data from the string
* @return string is not formmatedd correctly return false,
* else return true
*/
virtual bool initialize(istream& is);
// -------------------------------------------------------------------------
/** getType()
* get command type
*
* Return the type of book
* @pre None
* @post None. const
* @return char representing command type
*/
string getType() const;
// -------------------------------------------------------------------------
/** display()
* Display book information
*
* Display command information in east to read columns
* @param ostream outstream containing commands to display
* @pre None.
*/
virtual void display(ostream& os) const;
protected:
// patron and book databases
PatronDatabase* patronDB;
BookDatabase* bookDB;
// character indicating command
char commandCode;
// Command Type
string type;
// ID of patron this command uses
Patron* patron;
// ID of book this command uses
Book* book;
};
#endif