Ejemplo n.º 1
0
class CalculatorController:
    def __init__(self):
        self.model = CalculatorModel()

    @staticmethod
    def print_menu():
        print('0.  종료')
        print('1.  +')
        print('2.  -')
        print('3.  *')
        print('4.  /')
        menu = input('메뉴 선택\n')
        return int(menu)

    def run(self):
        model = self.model
        while 1:
            menu = self.print_menu()
            if menu == 0:
                break
            elif menu == 1:
                self.model.input_number()
                self.show('PLUS RESULT IS %d' % model.plus())
            elif menu == 2:
                self.show('MINUS RESULT IS %d')
            elif menu == 3:
                self.show('MULTI RESULT IS %d')
            elif menu == 4:
                self.show('DIVID RESULT IS %d')

    @staticmethod
    def show(param):
        print('RESULT : %s' % param)
Ejemplo n.º 2
0
class CalculatorController:
    def __init__(self, num1, num2):
        self.calc = CalculatorModel(num1, num2)

    def exec(self, op):
        if op == '+':
            return self.calc.add()
        elif op == '-':
            return self.calc.sub()
        elif op == '*':
            return self.calc.mul()
        else:
            return self.calc.div()
Ejemplo n.º 3
0
class CalculatorController:
    def __init__(self, num1, num2, op):
        self.op = op
        self.calc = CalculatorModel(num1, num2)

    def execute(self):
        if self.op == '+':
            result = self.calc.add()
        elif self.op == '-':
            result = self.calc.sub()
        elif self.op == '*':
            result = self.calc.mul()
        elif self.op == '/':
            result = self.calc.div()
        return result
Ejemplo n.º 4
0
class CalculatorController:
    def __init__(self, n1, n2):

        self.calc = CalculatorModel(n1, n2)

    def exec(self, op):
        if op == '+':
            result = self.calc.a1()
        elif op == '-':
            result = self.calc.a2()
        elif op == '*':
            result = self.calc.a3()
        elif op == '/':
            result = self.calc.a4()
        return result
Ejemplo n.º 5
0
class CalculatorController:
    def __init__(self,num1,num2):
        self.calc = CalculatorModel(num1,num2) #CalculatorModel클래스에대한 인스턴스 (calc), 생성자 (CalculatorModel)

    def exec(self, op):
        if op == '+':
            result = self.calc.add()

        elif op == '-':
            result = self.calc.sub()

        elif op == '*':
            result = self.calc.mul()

        elif op == '/':
            result = self.calc.div()

        return result
Ejemplo n.º 6
0
class CaculatorController:
    def __init__(self):
        num1 = int(input("첫번째 값 : \n"))
        num2 = int(input("두번째 값 : \n"))
        # op = input("연산자 입력 : \n")
        self.calc = CalculatorModel(num1, num2)

    def exe(self):
        op = input('연산자 입력 : ')
        if op == '+':
            result = self.calc.add()
        elif op == '-':
            result = self.calc.sub()
        elif op == '*':
            result = self.calc.mul()
        elif op == '/':
            result = self.calc.div()

        return result
Ejemplo n.º 7
0
from calculator.model import CalculatorModel
import os

if __name__ == '__main__':
    calc = CalculatorModel()  # 생성자는 끝에 ()
    if not os.path.exists('saved_add_model/checkpoint'):
        calc.create_add_model()

    if not os.path.exists('saved_mul_model/checkpoint'):
        calc.create_mul_model()

    if not os.path.exists('saved_div_model/checkpoint'):
        calc.create_div_model()

    if not os.path.exists('saved_sub_model/checkpoint'):
        calc.create_sub_model()
Ejemplo n.º 8
0
 def __init__(self, num1, num2):
     self.calc = CalculatorModel(num1, num2)
Ejemplo n.º 9
0
 def __init__(self, num1, num2, op):
     self.op = op
     self.calc = CalculatorModel(num1, num2)
Ejemplo n.º 10
0
from calculator.model import CalculatorModel
import os

if __name__ == '__main__':
    calc = CalculatorModel()

    if not os.path.exists('saved_add_model/checkpoint'):
        calc.create_add_model()
    if not os.path.exists('saved_sub_model/checkpoint'):
        calc.create_sub_model()
        """
    if not os.path.exists('saved_mul_model/checkpoint'):
        calc.create_mul_model()
    if not os.path.exists('saved_div_model/checkpoint'):
        calc.create_div_model()
       """
Ejemplo n.º 11
0
 def __init__(self):
     self.model = CalculatorModel()
Ejemplo n.º 12
0
from calculator.model import CalculatorModel
import os
if __name__ == '__main__':
    calc = CalculatorModel()
    calc.create_div_model()
    #리눅스에서 돌아간다
    #모델이 존재하지 않을경우만 실행한다.
    #모델을 공유하여 생성하기떄문에 같이 실행하면 뒤에 모델은 추가되어 생성되기 때문에 오륩라생
    #if not os.path.exists('saved_add_model/checkpoint'):
    #    calc.create_add_model()
    #if not os.path.exists('saved_min_model/checkpoint'):
    #    calc.create_min_model()
    #if not os.path.exists('saved_mul_model/checkpoint'):
    #    calc.create_mul_model()
    #if not os.path.exists('saved_div_model/checkpoint'):
    #    calc.create_div_model()
Ejemplo n.º 13
0
 def __init__(self,num1,num2):
     self.calc = CalculatorModel(num1,num2) #CalculatorModel클래스에대한 인스턴스 (calc), 생성자 (CalculatorModel)
Ejemplo n.º 14
0
    def __init__(self, n1, n2):

        self.calc = CalculatorModel(n1, n2)
Ejemplo n.º 15
0
 def __init__(self):
     num1 = int(input("첫번째 값 : \n"))
     num2 = int(input("두번째 값 : \n"))
     # op = input("연산자 입력 : \n")
     self.calc = CalculatorModel(num1, num2)
Ejemplo n.º 16
0
from calculator.model import CalculatorModel
import os

if __name__ == '__main__':
    calc = CalculatorModel()

    # calc.create_add_model()  -> add_model만 설정했을 경우

    if not os.path.exists(
            'saved_add_model/checkpoint'):  # 체크포인트를 기준으로 모델이 존재하는지 아닌지 판단
        calc.create_add_model()  # 모델이 없으면 만든다는 구문
    if not os.path.exists('saved_sub_model/checkpoint'):
        calc.create_sub_model()
    if not os.path.exists('saved_mul_model/checkpoint'):
        calc.create_mul_model()
    if not os.path.exists('saved_div_model/checkpoint'):
        calc.create_div_model()
"""  
 
    calc.create_add_model() # (1) add_model만 설정

    if not os.path. exists('saved_add_model/checkpoint'): # (2) add model설정된 후, 현재 행 포함 3행으로 설정
         calc.create_add_model() # 모델이 없으면 만든다는 구문
    calc.create_sub_model()
 
    if not os.path. exists('saved_sub_model/checkpoint'): # (3) (2)에서 submodel까지 설정된 후, mul model설정
        calc.create_sub_model()
    calc.create_mul_model()
    
    을 만든 후
    다음 조건 설정