Exemplo n.º 1
0
 def __init__(self):
     num1 = int(input('첫번째 수'))
     num2 = int(input('두번째 수'))
     calc = Service(num1, num2)
     op = input('연산자 입력')
     result = calc.exec(op)
     print('계산결과: %d' % result)
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 6
0
    def create(self, request, *args, **kwargs):
        name = request.data['name']
        word = request.data['word']
        data = {}
        if word:
            data = Service.calculate_Score(self, name, word)

            UserEntry.objects.create(**data)
            response = {
                'message': 'Entry Created',
                'name': request.data['name'],
                'word': request.data['word'],
                'score': data['score']
            }
            return Response(response, status=status.HTTP_200_OK)
        else:
            data['score'] = 0
            response = {
                'message': 'No letters found',
                'name': request.data['name'],
                'word': request.data['word'],
                'score': data['score']
            }
            return Response(response, status=status.HTTP_404_NOT_FOUND)
Exemplo n.º 7
0
 def test_calculate_number_word_score(self):
     res = Service.calculate_Score(self, "muzamir", 123)
     self.assertEqual(res.get("score"), 0)
Exemplo n.º 8
0
 def test_calculate_score(self):
     res = Service.calculate_Score(self, "muzamir", "back")
     self.assertEqual(res.get("score"), 27)