Skip to content

Instantly share code, notes, and snippets.

@marcelogdeandrade
Created June 21, 2018 02:01
Show Gist options
  • Save marcelogdeandrade/7e338e9def9b5c04a0ec65cf95522374 to your computer and use it in GitHub Desktop.
Save marcelogdeandrade/7e338e9def9b5c04a0ec65cf95522374 to your computer and use it in GitHub Desktop.
class Number():
def __init__(self, value):
self.value = value
def eval(self):
return int(self.value)
class BinaryOp():
def __init__(self, left, right):
self.left = left
self.right = right
class Sum(BinaryOp):
def eval(self):
return self.left.eval() + self.right.eval()
class Sub(BinaryOp):
def eval(self):
return self.left.eval() - self.right.eval()
class Print():
def __init__(self, value):
self.value = value
def eval(self):
print(self.value.eval())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment