1 글 보임 - 1 에서 1 까지 (총 1 중에서)
-
글쓴이글
-
2020년 4월 10일 4:55 오후 #7788
허 진경
키 마스터명함관리 프로그램…
고객관리 프로그램과 명함관리 프로그램의 차이점은?????
– 정보를 저장할 클래스가 다르다.
– 객체의 데이터가 다르다.
– 관리프로그램이라면… CRUD(Create(데이터 입력), Read(조회), Update(수정), Delete(삭제)
– 명함관리 프로그램의 주요 객체는 명함
명함에 저장할 데이터는… 이름, 전화번호, 이메일, 회사명
– 메뉴는…
입력(1), 수정(2), 조회(3), 삭제(4), 종료(0) <– 선택
(I)nsert, (U)pdate, (S)earch, (D)elete, (Q)uitclass NameCard: def __init__(self, name, phone, email, office): self.name = name self.phone = phone self.email = email self.office = office def __str__(self): return "name: {}, phone: {}, email: {}, phone: {}"\ .format(self.name, self.email, self.phone, self.office)
def get_menu(): while True: try: menu = int(input("메뉴: ")) return menu except: print("메뉴를 잘 못 입력했습니다. 다시 입력하세요.")
def get_namecard_info(): name = input("이름: ") phone = input("전호번호: ") email = input("이메일: ") office = input("회사명: ") card = NameCard(name, phone, email, office) return card
def find_namecard(namecard_list, phone): for i, card in enumerate(namecard_list): if phone==card.phone: return i return -1
namecard_list = [] #전역변수
while True: print("입력(1), 수정(2), 조회(3), 삭제(4), 종료(0)") menu = get_menu() if menu==1: new_card = get_namecard_info() namecard_list.append(new_card) elif menu==2: find_phone = input("수정할 명함의 전화번호 : ") index = find_namecard(namecard_list, find_phone) if index>=0: update_card = get_namecard_info() namecard_list[index] = update_card else: print("수정할 데이터를 찾지 못했습니다.") elif menu==3: find_phone = input("찾을 명함의 전화번호 : ") index = find_namecard(namecard_list, find_phone) if index>=0: print(namecard_list[index]) else: print("데이터를 찾지 못했습니다.") elif menu==4: find_phone = input("삭제할 명함의 전화번호 : ") index = find_namecard(namecard_list, find_phone) if index>=0: del namecard_list[index] else: print("삭제할 데이터를 찾지 못했습니다.") elif menu==5: for card in namecard_list: print(card) elif menu==0: break
-
이 게시글은
허 진경에 의해 1 year 전에 수정됐습니다.
-
이 게시글은
-
글쓴이글
1 글 보임 - 1 에서 1 까지 (총 1 중에서)
답변은 로그인 후 가능합니다. Login here