-
Notifications
You must be signed in to change notification settings - Fork 0
/
node.py
51 lines (37 loc) · 1.16 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
class MyNode:
def __init__(self, point, axis, height, rectangle):
self.value = point
self.left = None
self.right = None
self.parent = None
self.axis = axis
self.rectangle = rectangle
self.height = height
def __repr__(self) -> str:
return "<NODE> - {}".format(self.getValue())
def __str__(self) -> str:
return "<NODE> - {}".format(self.getValue())
def __eq__(self, o: object) -> bool:
return self.value[0] == o.value[0] and self.value[1] == o.value[1]
def hasChild(self):
return self.right or self.left
def hasRightChild(self):
return True if self.right else False
def hasLeftChild(self):
return True if self.left else False
def getRectangle(self):
return self.rectangle
def getHeight(self):
return self.height
def getRightChild(self):
return self.right
def getLeftChild(self):
return self.left
def getValue(self):
return self.value
def getX(self):
return self.value[0]
def getY(self):
return self.value[1]
def getAxis(self):
return self.axis