Created
June 21, 2018 02:01
-
-
Save marcelogdeandrade/7e338e9def9b5c04a0ec65cf95522374 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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