Beispiel #1
0
 def __init__(self):
     num1 = int(input('첫번째 수'))
     num2 = int(input('두번째 수'))
     calc = Service(num1, num2)
     op = input('연산자 입력')
     result = calc.exec(op)
     print('계산결과: %d' % result)
Beispiel #2
0
 def calc(self, num1, num2, opcode):
     model = Model()
     model._num1 = num1
     model._num2 = num2
     model._opcode = opcode
     service = Service(model)
     if opcode == "+": result = service.add()
     if opcode == "-": result = service.minus()
     if opcode == "*": result = service.multiplication()
     if opcode == '/': result = service.divide()
     return result
Beispiel #3
0
 def calc(self, num1, num2, opcode):
     model = Model()
     model.num1 = num1
     model.num2 = num2
     model.opcode = opcode
     service = Service(model)
     if opcode == '+': result = service.add()
     if opcode == '-': result = service.minus()
     if opcode == '*': result = service.multi()
     if opcode == '/': result = service.divide()
     return result
Beispiel #4
0
 def calc(self, num1, num2, opcode):
     model = Model()  #new Model 과 같다
     model.num1 = num1
     model.num2 = num2
     model.opcode = opcode
     service = Service(model)
     if opcode == '+':
         result = service.add()  # 자바 스크립트와 달리 파이썬은 ' '  이것이 == 과같은 역할을 한다
     if opcode == '-': result = service.minus()
     if opcode == '*': result = service.multi()
     if opcode == '/': result = service.divide()
     return result
Beispiel #5
0
 def excute(self, num1, num2, opcode):
     entity = Entity()
     entity.num1 = num1
     entity.num2 = num2
     entity.opcode = opcode
     service = Service(entity)
     if opcode == '+':
         result = service.add()
     if opcode == '-':
         result = service.subtract()
     if opcode == '*':
         result = service.multiply()
     if opcode == '/':
         result = service.divide()
     return result