class ContactsController: def __init__(self): self.model = ContactsModel() @staticmethod def print_menu(): print('1. 연락처 입력: ') print('2. 연락처 출력: ') print('3. 연락처 삭제: ') print('0. 종료: ') menu = input('메뉴 선택\n') return menu def run(self): contacts = [] while 1: menu = self.print_menu() print('메뉴: %s' % menu) if menu == '1': name = input('이름\n') phone = input('전화번호\n') email = input('이메일\n') addr = input('주소\n') t = self.model.set_contact(name, phone, email, addr) contacts.append(t) elif menu == '2': print(self.model.get_contacts(contacts)) elif menu == '3': name = input('삭제할 이름') self.model.del_contact(contacts, name) elif menu == '0': print('시스템 종료') break
class ContactsController: def __init__(self): self.model = ContactsModel() @staticmethod def print_menu(): print('1, 연락처 입력:') print('2, 연락처 출력:') print('3, 연락처 삭제:') print('0, 종료:') menu = int(input('메뉴 선택')) return menu def run(self): params = [] while 1: menu = self.print_menu() if menu == 1: n1 = input("이름\n") n2 = input("전화번호\n") n3 = input("이메일\n") n4 = input("주소\n") t = self.model.set_contact(n1, n2, n3, n4) params.append(t) elif menu == 2: print(self.model.get_contacts(params)) elif menu == 3: n1 = input('삭제할 이름') self.model.del_contact(params, n1) elif menu == 0: print('시스템 종료') break
class ContactsController: def __init__(self): self.model = ContactsModel() #staticmethod와 self의 정확한 사용 용도 @staticmethod def print_menu(): print('1, 연락처 입력 :') print('2, 연락처 출력 :') print('3, 연락처 삭제 :') print('0, 종로 :') menu = input('메뉴 선택') return menu def run(self): contacts = [] while 1: menu = self.print_menu() if(menu == '1'): name = input('이름') phone = input('전화번호') addr = input('주소') email = input('이메일') t = self.model.set_contact(name, phone, addr, email) contacts.append(t) elif(menu == '2'): print(self.model.get_contacts(contacts)) elif(menu == '3'): name = input('이름') self.model.del_contact(contacts, name) elif(menu == '0'): print("시스템 종료") break
class ContactsController: def __init__(self): self.model = ContactsModel() @staticmethod def print_menu(): print('1. 연락처 입력') print('2. 연락처 츨력') print('3. 연락처 삭제') print('0. 종료') menu = int(input('메뉴 선택 : ')) return menu def run(self): contacts = [] while 1: menu = self.print_menu() print('메뉴 : %s' % menu) if menu == 1: n = input('이름 : ') p = input('전화번호 : ') e = input('이메일 : ') a = input('주소 : ') t = self.model.set_contact(n, p, e, a) contacts.append(t) elif menu == 2: print(self.model.get_contacts(contacts)) elif menu == 3: n = input('삭제할 이름 : ') self.model.del_contact(contacts, n) elif menu == 0: print('시스템 종료') break
def register(self, name, phone, email, addr): model = ContactsModel() model.name = name model.phone = phone model.email = email model.addr = addr self._service.add_contact(model)
class ContactsController: def __init__(self): # 모델 인스턴스화 self.model = ContactsModel() @staticmethod def menuPrint(): print('1.입력') print('2.출력') print('3.삭제') print('4.수정') print('0.종료') menu =int(input('메뉴선택?\n')) return menu def run(self): contacts =[] while 1: menu = self.menuPrint() if menu ==1 : name = input('name?') phone = input('phone?') email = input('email?') addr = input('address?') contact=self.model.setContact(name, phone, email, addr) contacts.append(contact) elif menu ==2: print(self.model.getContact(contacts)) elif menu ==3: name=input('삭제할 이름?') self.model.deleteContact(contacts,name) elif menu==0: print('프로그램을 종료합니다') break
def __init__(self): self.model = ContactsModel()
def __init__(self): # 모델 인스턴스화 self.model = ContactsModel()