-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.cpp
More file actions
86 lines (71 loc) · 1.63 KB
/
command.cpp
File metadata and controls
86 lines (71 loc) · 1.63 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
86
/*
* command.cpp
*
* @authors Juan Arias & Nick Tibbott
*
* Built in Command subclass implemntations
*
*/
#include "store.h"
#include "command.h"
/*
* Protected constructor for subclasses to set store pointer
*/
Command::Command(Store* store, const string& fileName)
:store(store), fileName(fileName) {
}
/*
* Virtual destructor
*/
Command::~Command() {
}
/*
* Constructs an AddCustomer object with a given store and line
*/
AddCustomer::AddCustomer(Store* store, long customerID, const string& name)
:Command(store), customerID(customerID), name(name) {
}
/*
* Execute the command
*/
void AddCustomer::execute() const {
store->addCustomer(customerID, name);
}
/*
* Constructs an AddCustomer object with a given store and line
*/
RemoveCustomer::RemoveCustomer(Store* store, long customerID)
:Command(store), customerID(customerID) {
}
/*
* Execute the command
*/
void RemoveCustomer::execute() const {
store->removeCustomer(customerID);
}
/*
* Constructs an AddItem object with a given store, itemType, media and line
*/
AddItem::AddItem(Store* store, const ItemType* itemType, const Media* media,
const string& fileName, const string& line)
:Command(store, fileName), itemType(itemType), media(media), line(line) {
}
/*
* Execute the command
*/
void AddItem::execute() const {
store->addItem(itemType, media, fileName, line);
}
/*
* Constructs a DisplayError object with a given store and error line
*/
DisplayError::DisplayError(Store* store, const string& fileName,
const string& line)
:Command(store, fileName), line(line) {
}
/*
* Execute the command
*/
void DisplayError::execute() const {
store->displayError(fileName, line);
}