-
Notifications
You must be signed in to change notification settings - Fork 0
/
node.py
53 lines (41 loc) · 1.54 KB
/
node.py
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
import uuid
class Node(object):
def __init__(self, value, color):
self.setValue(value)
self.setColor(color)
self.__uuid = uuid.uuid1()
self.__leftNode = None
self.__rightNode = None
self.__parentNode = None
def setLeftNode(self, node):
if (node != None and type(node).__name__ != 'Node'):
raise Exception('value should be a Node: {}'.format(node))
self.__leftNode = node
def setRightNode(self, node):
if (node != None and type(node).__name__ != 'Node'):
raise Exception('value should be a Node: {}'.format(node))
self.__rightNode = node
def getLeftNode(self):
return self.__leftNode
def getRightNode(self):
return self.__rightNode
def setValue(self, value):
if (type(value).__name__ != 'int'):
raise Exception('value should be an integer: {}'.format(value))
self.__value = value
def getValue(self):
return self.__value
def setColor(self, color):
if (type(color).__name__ != 'Color'):
raise Exception('color should be a Color: {}'.format(color))
self.__color = color
def getColor(self):
return self.__color
def setParentNode(self, node):
if (node != None and type(node).__name__ != 'Node'):
raise Exception('value should be a Node: {}'.format(node))
self.__parentNode = node
def getParentNode(self):
return self.__parentNode
def getUUID(self):
return self.__uuid