Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class InputObject:
- def __init__(self, name):
- self.name = name
- class Operation(InputObject):
- """Operation class"""
- def __init__(self,oper ,lhs, rhs):
- self.oper = oper.lower()
- self.lhs = lhs
- self.rhs = rhs
- def executeOperation(self):
- print("printar oper: ")
- print(self.oper)
- def addition(lhs, rhs):
- print("inne i add")
- lhs.value = lhs.value+rhs.value
- def subtraction(lhs, rhs):
- print("inne i sub")
- lhs.value = lhs.value-rhs.value
- def multiplication(lhs, rhs):
- print("inne i mult")
- lhs.value = lhs.value*rhs.value
- if (self.oper == "add"):
- addition(self.lhs, self.rhs)
- elif (self.oper == "minus"):
- subtraction(self.lhs, self.rhs)
- elif (self.oper == "mult"):
- multiplication(self.lhs, self.rhs)
- else:
- print("ogiltid operation")
- pass
- class Value(InputObject):
- """ value class"""
- def __init__(self, name):
- #if (isinstance(float(name),float)):
- if (name.isdigit() or name.isdecimal()):
- self.name = name
- self.value = float(name) #fixa rätt med decimaler sen, fråga ante
- else:
- self.name = name
- self.value = 0
- class Register(InputObject):
- """Register class"""
- def __init__(self, name):
- self.name = name
- self.value = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement