Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/plotter/view/puzzletree/nodes/binaryoperator.py
diff options
context:
space:
mode:
Diffstat (limited to 'plotter/view/puzzletree/nodes/binaryoperator.py')
-rwxr-xr-xplotter/view/puzzletree/nodes/binaryoperator.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/plotter/view/puzzletree/nodes/binaryoperator.py b/plotter/view/puzzletree/nodes/binaryoperator.py
new file mode 100755
index 0000000..97208e5
--- /dev/null
+++ b/plotter/view/puzzletree/nodes/binaryoperator.py
@@ -0,0 +1,30 @@
+from .node import Node as _Node
+
+
+class BinaryOperator(_Node):
+ """BinaryOperators have at most two children."""
+
+ def __init__(self, leftchild=None, rightchild=None):
+ """Create binary operator (possibly with children)."""
+ _Node.__init__(self)
+ self.children = [leftchild, rightchild]
+
+
+ @classmethod
+ def load(nodeclass, settings):
+ """Creates a new BinaryOperator of type nodeclass.
+
+ Default BinaryOperators don't have any parameters,
+ so this just returns a new node.
+ """
+ return nodeclass()
+
+
+ def get_equation_string(self, variable):
+ """Returns a string representing the current equation."""
+
+ return "(%s %s %s)" % (
+ _Node.get_equation_string(self.children[0], variable),
+ self.operatorstring,
+ _Node.get_equation_string(self.children[1], variable))
+