-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinkedListNode.cpp
More file actions
61 lines (56 loc) · 1.47 KB
/
Copy pathlinkedListNode.cpp
File metadata and controls
61 lines (56 loc) · 1.47 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
/**
* @file linkedListNode.h
* @author Alex Lambert
*
* Description:
* -Stores a command and the next link in the list
* -Allows for the command to be executed, but never changed
*
* Assumptions/Implementation:
* -A linked list node must not exist without a command
* -The command will be deleted when this node is deleted
*/
#include "linkedListNode.h"
//---------------------------------------------------------------------------
/** LinkedListNode()
* Default Constructor
*
* Creates a Linked List Node with the given command
* @param command The command to be executed when the queue is ready
* @pre Command is not a nullptr
* @post the command is stored and next is set to nullptr
*/
LinkedListNode::LinkedListNode(LibraryCommand* command)
{
this->command = command;
next = nullptr;
}
//---------------------------------------------------------------------------
/** ~LinkedListNode()
* Default Destructor
*
* Destroys the Linked List Node
* @pre None
* @post Deallocates this node and its enclosed Library Command
*/
LinkedListNode::~LinkedListNode()
{
delete command;
command = nullptr;
if (next) {
delete next;
next = nullptr;
}
}
//---------------------------------------------------------------------------
/** execute()
* Execute Command
*
* Executes the enclosed Library Command
* @pre None
* @post The library command executed, this is unchanged
*/
void LinkedListNode::execute()
{
command->execute();
}