-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTreeNode.cpp
More file actions
63 lines (50 loc) · 1.12 KB
/
TreeNode.cpp
File metadata and controls
63 lines (50 loc) · 1.12 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
#include "TreeNode.h"
/* These are all getters and setters except for the last function */
void TreeNode::setItem(char anItem)
{
item = anItem;
}
void TreeNode::setItem(std::string anItem)
{
item = anItem;
}
std::string TreeNode::getItem() const
{
return item;
}
TreeNode* TreeNode::getLeftChildPtr() const
{
// Return the address of leftChild
return leftChild;
}
TreeNode* TreeNode::getRightChildPtr() const
{
// Return the address of rightChild
return rightChild;
}
TreeNode* TreeNode::getParentPtr()
{
return parent;
}
void TreeNode::setLeftChildPtr(TreeNode* leftPtr)
{
// Change the address of the leftChild currently point to
leftChild = leftPtr;
}
void TreeNode::setRightChildPtr(TreeNode* rightPtr)
{
// Change the address of the rightChild currently point to
rightChild = rightPtr;
}
void TreeNode::setParentPtr(TreeNode* parentPtr)
{
parent = parentPtr;
}
/* Checks if the given string/char is an operator */
bool TreeNode::isOperator(std::string ch)
{
if (ch[0] == '+' || ch[0] == '-' || ch[0] == '/' || ch[0] == '*') {
return true;
}
return false;
}