Guest User

Untitled

a guest
Jun 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. class Number():
  2. def __init__(self, value):
  3. self.value = value
  4.  
  5. def eval(self):
  6. return int(self.value)
  7.  
  8.  
  9. class BinaryOp():
  10. def __init__(self, left, right):
  11. self.left = left
  12. self.right = right
  13.  
  14.  
  15. class Sum(BinaryOp):
  16. def eval(self):
  17. return self.left.eval() + self.right.eval()
  18.  
  19.  
  20. class Sub(BinaryOp):
  21. def eval(self):
  22. return self.left.eval() - self.right.eval()
  23.  
  24.  
  25. class Print():
  26. def __init__(self, value):
  27. self.value = value
  28.  
  29. def eval(self):
  30. print(self.value.eval())
Add Comment
Please, Sign In to add comment