6/3_Python PC방 키오스크 제작

2025. 6. 3. 22:00·Python/Project

 

 

 

 

 

 

 

 

 

 

 

 

🌟 초반 키오스크 코드

더보기
import os
if 'TERM' not in os.environ:
    os.environ['TERM'] = 'xterm-256color'
from console_art import login_art, main_art, guest_login_art, time_charge_art, menu_list_all, menu_list_set, menu_list_drink, menu_list_food

def clear_console():
    os.system('cls' if os.name == 'nt' else 'clear')

def time():
    clear_console()
    print(time_charge_art)
    time_db = {
        '1000': ['00:40'],
        '2000': ['01:20'],
        '3000': ['02:00'],
        '5000': ['03:30'],
        '10000': ['07:10'],
        '20000': ['14:30'],
        '30000': ['22:10'],
        '50000': ['37:00']
    }
    charge_time = input("충전할 요금을 선택해 주세요.")
    if charge_time in time_db:
        selceted_times = []
        selceted_times.append(time_db[charge_time])
        print(f"충전할 시간 : {time_db[charge_time]}")
    else:
        print(f"해당 시간의 요금제는 없습니다: {charge_time}")

# 미리 등록된 사용자 데이터 (아이디, 비밀번호)
user_db = {
    '관리자': ['admin', '1q2q3e'],
    '수민': ['lsm1103', 'Qwer1103'],
    '영주': ['1103', '1103'],
    '진리' : ['123', '123']
}

def login():
    clear_console()
    print(login_art)
    user_id = input("    >> 아이디를 입력하세요: ")
    password = input("    >> 비밀번호를 입력하세요: ")

    for username, credentials in user_db.items():
        if credentials[0] == user_id and credentials[1] == password:
            clear_console()
            print(f"    {' ̄' * 40}")
            print(f"       {username}님, 아이센스리그 PC방에 오신 것을 환영합니다! 즐거운 시간 되세요!")
            print(f"    {' ̄' * 40}")
            input("    >> 계속하려면 Enter 키를 누르세요.")
            clear_console()
            return True

    print("    >> 등록된 정보가 없습니다. 관리자에게 문의하세요.")
    input("    >> 다시 시도하려면 Enter 키를 누르세요.")
    return False


def guest_login():
    clear_console()
    print(guest_login_art)
    print("    비회원 로그인 창")
    print("    사용하실 PC 번호를 입력하세요 (예: 1 ~ 50)")

    while True:
        pc_number = input("    >> PC 번호 입력: ").strip()
        if not pc_number.isdigit():
            print("    >> 숫자만 입력해주세요.")
            continue

        pc_num = int(pc_number)
        if 1 <= pc_num <= 50:  # PC방 자리 개수에 맞게 조절
            break
        else:
            print("    >> 올바른 번호를 입력해주세요 (1~50).")

    clear_console()
    print(guest_login_art)
    print(f"    {' ̄' * 40}")
    print(f"       PC 번호 {pc_num}번으로 접속하셨습니다! 즐거운 시간 되세요!")
    print(f"    {' ̄' * 40}")
    input("    >> 계속하려면 Enter 키를 누르세요.")
    clear_console()
    return True

cart = []
def menu_list():
    clear_console()
    menu_db = {
        '전체': [
            '콜라', '사이다', '환타', '커피', '녹차', '라면', '김밥', '떡볶이', '감자튀김',
            '핫도그', '라면+콜라 세트', '김밥+사이다 세트', '떡볶이+환타 세트'
        ],
        '세트': ['라면+콜라 세트', '김밥+사이다 세트', '떡볶이+환타 세트'],
        '음료': ['콜라', '사이다', '환타', '커피', '토레타', '에너지드링크'],
        '식사': ['라면', '김밥', '떡볶이', '햄버거', '핫도그', '샌드위치']
    }

    option_db = {
        '세트': ['L', 'M', '감자튀김', '핫도그', '멘보샤', '만두튀김', '순살치킨'],
        '음료': ['L', 'M'],
        '식사': ['감자튀김', '핫도그', '멘보샤', '만두튀김', '순살치킨']
    }

    # 메뉴 입력
    print(menu_list_all)
    user_input = input("메뉴를 입력하세요 (여러 개: 콤마로 구분): ")
    user_choices = [item.strip() for item in user_input.split(',')]

    selected_menus = []
    for choice in user_choices:
        if choice in menu_db['전체']:
            selected_menus.append(choice)
        else:
            print(f"❌ 해당 메뉴가 없습니다: {choice}")

    if not selected_menus:
        print("선택한 유효한 메뉴가 없습니다.")
        return

    print("✅ 선택한 메뉴:", selected_menus)

    # 각 메뉴의 카테고리를 확인해 옵션 제공
    for menu in selected_menus:
        menu_category = None
        for category in ['세트', '음료', '식사']:
            if menu in menu_db[category]:
                menu_category = category
                break

        if menu_category and menu_category in option_db:
            print(f"\n[옵션 선택] {menu} ({menu_category}) → 사용 가능한 옵션: {', '.join(option_db[menu_category])}")
            option_input = input("옵션을 입력하세요 (공백으로 구분, 없으면 Enter): ").split()
            selected_options = [opt for opt in option_input if opt in option_db[menu_category]]
        else:
            selected_options = []

        cart.append({
            '메뉴': menu,
            '옵션': selected_options
        })

    print("\n🛒 현재 장바구니:")
    for item in cart:
        print(f"- {item['메뉴']} / 옵션: {', '.join(item['옵션']) if item['옵션'] else '없음'}")
clear_console()
def main_screen():
    while True:
        print("     아이센스리그 PC방에 오신 것을 환영합니다!")
        print("    1. 시간구매")
        print("    2. 음식 주문")
        menu_choice = input("    >> 메뉴를 입력하세요: ")

        if menu_choice == '1':
            time()
            break# 여기에 break 조건을 넣고 싶다면 수정 필요
        elif menu_choice == '2':
            menu_list()
            break
        else:
            print("    >> 올바른 메뉴를 선택해주세요.")
            input("    >> 계속하려면 Enter 키를 누르세요.")

        print("    " + " ̄" * 32)
        break
    clear_console()

def main():
    while True:
        clear_console()
        print(main_art)
        print("    1. 로그인")
        print("    2. 비회원 로그인")
        choice = input("    >> 메뉴를 선택하세요: ")

        if choice == '1':
            if login():
                main_screen()  # 로그인 성공 후 메뉴 화면으로 이동
                break
        elif choice == '2':
            if guest_login():
                main_screen()  # 비회원 로그인 성공 후 메뉴 화면으로 이동
                break
        else:
            print("    >> 올바른 메뉴를 선택해주세요.")
            input("    >> 계속하려면 Enter 키를 누르세요.")

if __name__ == "__main__":
    main()

 

초반에 제작하던 키오스크다. 이 코드는 추가해야 할 부분이 많았다. 카테고리는 여러개 제작했으면서 종작 프린트는 전체 아트밖에 출력을 하지 않는다. 심지어 선택하는 코드도 없을 뿐더러 마지막 메뉴 선택하고 난 후에 요금을 결제하는 로직도 추가되지 않았다. 또한 음식의 가격과 장바구니에 추가될 최종 가격에 대해서는 없다. 그래서 한 번 추가를 해보았다.

 

 

 

 

🌟 현재 키오스크 코드

더보기
import os
if 'TERM' not in os.environ:
    os.environ['TERM'] = 'xterm-256color'
from console_art import login_art, main_art, guest_login_art, time_charge_art, menu_list_all, menu_list_set, menu_list_drink, menu_list_food, menu_list_option_food, menu_list_food_side

def clear_console():
    os.system('cls' if os.name == 'nt' else 'clear')

def time(): #이용권 함수
    time_db = {
        '1000': ['00:50'],
        '2000': ['01:30'],
        '3000': ['02:00'],
        '5000': ['03:30'],
        '10000': ['07:30'],
        '20000': ['14:30'],
        '30000': ['22:30'],
        '50000': ['37:00']
}
    while True:
        clear_console()
        print(time_charge_art)
        print("충전할 요금을 선택해 주세요.")
        charge_price = int(input()) #지불할 금액
        lst = ['1000','2000','3000','5000','10000','20000','30000','50000']
        charge_price = lst[charge_price-1]
        if charge_price in time_db:
            selceted_times = []
            selceted_times.append(time_db[charge_price])
            print(f"충전할 시간 : {time_db[charge_price]}")
            break
        else:
            print(f"System : 해당 시간의 요금제는 없습니다")
            continue
    return charge_price

def pay(charge_price): #결제함수
    print("지불할 금액 >>>", charge_price)
    print("0. 뒤로가기 1. 현금 2. 신용카드 3. 카카오페이")
    pay_way = int(input("결제방식 입력 >>>"))
    lst = ["뒤로가기","현금","신용카드","카카오페이"]
    pay_way = lst[pay_way]
    if pay_way == "현금":
        money = int(input("현금을 넣어 주세요 >>> "))
        change_money = money - int(charge_price)
        print("결제가 완료되었습니다.")
        print("거스름돈 >>> ", change_money)
        return True
    elif pay_way == "신용카드":
        print("카드를 삽입해 주세요.")
        print("결제가 완료되었습니다.")
        return True
    elif pay_way == "카카오페이":
        print("지정된 바코드를 찍어주세요.")
        print("결제가 완료되었습니다.")
        return True
    elif pay_way == "뒤로가기":
        print("이전화면으로 돌아갑니다.")
        return False
    else:
        print(f"System : 결제에 실패했습니다.")
        return False


# 미리 등록된 사용자 데이터 (아이디, 비밀번호)
user_db = {
    '관리자': ['admin', '1q2q3e'],
    '수민': ['lsm1103', 'Qwer1103'],
    '영주': ['1103', '1103'],
    '진리' : ['123', '123']
}

def login():
    clear_console()
    print(login_art)
    user_id = input("    >> 아이디를 입력하세요: ")
    password = input("    >> 비밀번호를 입력하세요: ")

    for username, credentials in user_db.items():
        if credentials[0] == user_id and credentials[1] == password:
            clear_console()
            print(f"     {' ̄'*35}")
            print(f"     {username}님, 아이센스리그 PC방에 오신 것을 환영합니다! 즐거운 시간 되세요!")
            print(f"     {' ̄'*35}")
            clear_console()
            return True

    print("    >> 등록된 정보가 없습니다. 관리자에게 문의하세요.")
    input("    >> 다시 시도하려면 Enter 키를 누르세요.")
    return False


def guest_login():
    clear_console()
    print(guest_login_art)

    while True:
        pc_number = input("    >> PC 번호 입력: ").strip()
        if not pc_number.isdigit():
            print("    >> 숫자만 입력해주세요.")
            continue

        pc_num = int(pc_number)
        if 1 <= pc_num <= 50:  # PC방 자리 개수에 맞게 조절
            break
        else:
            print("    >> 올바른 번호를 입력해주세요 (1~50).")

    clear_console()
    print(f"     {' ̄'*35}")
    print(f"     PC 번호 {pc_num}번으로 접속하셨습니다! 즐거운 시간 되세요!")
    print(f"     {' ̄'*35}")
    input("    >> 계속하려면 Enter 키를 누르세요.")
    clear_console()
    return True

cart = []
def menu_list():
    clear_console()
    menu_db = {
        '전체': [
            '콜라', '사이다', '환타', '커피', '녹차', '라면', '김밥', '떡볶이', '감자튀김',
            '핫도그', '라면+콜라 세트', '김밥+사이다 세트', '떡볶이+환타 세트', '햄버거'
        ],
        '세트': ['라면+콜라 세트', '김밥+사이다 세트', '떡볶이+환타 세트'],
        '음료': ['콜라', '사이다', '환타', '커피', '녹차', '토레타', '에너지드링크', '웰치스'],
        '식사': ['라면', '김밥', '떡볶이', '햄버거', '핫도그', '샌드위치']
    }

    price_db = {
        '라면+콜라 세트': 5000, '김밥+사이다 세트': 4000, '떡볶이+환타 세트': 3800, '감자튀김+핫도그+웰치스': 6500,
        '콜라': 1800, '사이다': 1800, '웰치스': 1500, '환타': 1500, '핫식스': 1800, '아메리카노': 2000,
        '커피': 2000, '녹차': 1500, '토레타': 1800, '에너지드링크': 2000,
        '라면': 3500, '김밥': 2500, '떡볶이': 3500, '햄버거': 3500, '볶음밥': 4500, '샌드위치': 3000
    }

    option_db = {
        '세트': ['L', 'M', '감자튀김', '핫도그', '멘보샤', '만두튀김', '순살치킨'],
        '음료': ['L', 'M'],
        '식사': ['감자튀김', '핫도그', '멘보샤', '만두튀김', '순살치킨']
    }

    option_price_db = {
         '감자튀김': 3000, '핫도그': 2500, '멘보샤': 3500, '만두튀김': 4000, '순살치킨': 5000, 'L': 800, 'M': 0
    }

    def print_menu_art(category):
        if category == "전체":
            print(menu_list_all)
        elif category == "세트":
            print(menu_list_set)
        elif category == "음료":
            print(menu_list_drink)
        elif category == "식사":
            print(menu_list_food)
        elif category == "사이드":
            print(menu_list_food_side)
        else:
            print("해당 카테고리의 메뉴가 없습니다.")

    # 1. 카테고리 선택
    while True:
        print("카테고리를 선택하세요:")
        for idx, cat in enumerate(menu_db.keys(), 1):
            print(f"{idx}. {cat}")
        cat_choice = input("번호 입력 또는 카테고리명 입력 >>> ").strip()

        categories = list(menu_db.keys())
        if cat_choice.isdigit():
            cat_idx = int(cat_choice) - 1
            if 0 <= cat_idx < len(categories):
                category = categories[cat_idx]
            else:
                print("올바른 번호를 입력하세요.")
                continue
        else:
            if cat_choice in menu_db:
                category = cat_choice
            else:
                print("올바른 카테고리를 입력하세요.")
                continue

        clear_console()
        print_menu_art(category)
        break  # 카테고리 선택 완료 후 나가기

    # 2. 메뉴 입력 (선택한 카테고리 내에서)
    while True:
        user_input = input("메뉴를 입력하세요 (여러 개: 콤마로 구분): ")
        user_choices = [item.strip() for item in user_input.split(',')]
        selected_menus = []

        for choice in user_choices:
            if choice in menu_db[category] or (category == '전체' and any(choice in menu_db[c] for c in ['세트','음료','식사'])):
                selected_menus.append(choice)
            else:
                print(f"❌ 해당 메뉴가 없습니다: {choice}")
        if not selected_menus:
            print("선택한 유효한 메뉴가 없습니다.")
            continue

        print("✅ 선택한 메뉴:", selected_menus)
        break


    # 3. 옵션 선택 및 장바구니 담기
    for menu in selected_menus:
        menu_category = None
        for cat in ['세트', '음료', '식사']:
            if menu in menu_db[cat]:
                menu_category = cat
                break

        if menu_category and menu_category in option_db:
            print(f"\n[옵션 선택] {menu} ({menu_category}) → 사용 가능한 옵션: {', '.join(option_db[menu_category])}")
            option_input = input("옵션을 입력하세요 (콤마로 구분, 없으면 Enter): ")
            option_input = [opt.strip() for opt in option_input.split(',') if opt.strip()]
            selected_options = [opt for opt in option_input if opt in option_db[menu_category]]
        else:
            selected_options = []

        cart.append({
            '메뉴': menu,
            '옵션': selected_options
        })
    total_price = 0
    clear_console()
    print("\n🛒 현재 장바구니:")
    for item in cart:
        menu_name = item['메뉴']
        base_price = price_db.get(menu_name, 0)
        option_list = item['옵션']

        # 옵션 가격 합산
        option_price = sum(option_price_db.get(opt, 0) for opt in option_list)
        item_total = base_price + option_price
        total_price += item_total

        option_str = ', '.join(option_list) if option_list else '없음'
        print(f"- {menu_name} ({base_price}원) + 옵션({option_price}원) → 합계: {item_total}원 / 옵션: {option_str}")

    print(f"\n💰 총 결제 금액: {total_price}원")

    if pay(str(total_price)):
        print("✅ 주문이 완료되었습니다.")
        cart.clear()
    else:
        print("❌ 주문이 취소되었습니다.")
    input("계속하려면 Enter 키를 누르세요.")

    # print("장바구니에서 삭제할 메뉴가 있습니까? (Y/N)")
    # if input().strip().lower() == 'y':
    #     for idx, item in enumerate(cart, 1):
    #         print(f"{idx}. {item['메뉴']} / 옵션: {', '.join(item['옵션'])}")
    #     del_idx = int(input("삭제할 항목 번호 입력: ")) - 1
    #     if 0 <= del_idx < len(cart):
    #         del cart[del_idx]


def main_screen():
    while True:
        print(f"     {' ̄'*35}")
        print("      1. 시간구매")
        print("      2. 음식 주문")
        print(f"     {' ̄'*35}")
        menu_choice = input("    >> 메뉴를 입력하세요: ")

        if menu_choice == '1':
            while True:
                if pay(time()):
                    break
                else:
                    continue
            break
        elif menu_choice == '2':
            menu_list()
            break
        else:
            print("    >> 올바른 메뉴를 선택해주세요.")
        print("    " + " ̄" * 32)
        continue
    clear_console()

def main():
    while True:
        clear_console()
        print(main_art)
        print("    1. 로그인")
        print("    2. 비회원 로그인")
        choice = input("    >> 메뉴를 선택하세요: ")

        if choice == '1':
            if login():
                main_screen()  # 로그인 성공 후 메뉴 화면으로 이동
                break
        elif choice == '2':
            if guest_login():
                main_screen()  # 비회원 로그인 성공 후 메뉴 화면으로 이동
                break
        else:
            print("    >> 올바른 메뉴를 선택해주세요.")

if __name__ == "__main__":
    main()

 

 앞서 말한 부분에 대해서는 모드 수정이 완료된 상태이다. 허나, 장바구니에서 수정하거나 삭제하는 란은 아직 제작하지 않아 주석으로 남겨두었다. 이 프로젝트는 팀원들과 함께 제작하였다. 팀원들이 아트와, 요금제, 결제, 옵션, 장바구니 부분을 제작해 주었고, 본인은 로그인, 비로그인, 메인화면, 장바구니 총 요금 부분과 결제하기, 각 카테고리별 아트 출력, 기타 등등을 했다. 성격이 급해서 혼자 앞서가서 팀원들이 날 따라와 줄 수 있을 지 의문이었지만 다들 열심히 따라와줘서 고마웠고 앞으로 속도 조절을 좀 해야 할것 같다...

 

 

 

 

 

 

 

 

 

 

 

 

미리보기용

 

'Python > Project' 카테고리의 다른 글

5/29_Python 야구, 로또  (0) 2025.05.29
'Python/Project' 카테고리의 다른 글
  • 5/29_Python 야구, 로또
eull
eull
eull 님의 블로그 입니다.
  • eull
    eull 님의 블로그
    eull
  • 전체
    오늘
    어제
    • 개발 환경 (34)
      • Qt (2)
        • API (0)
        • Project (2)
      • MYSQL_Workbench (1)
        • setting (1)
      • Linux_Ubuntu (2)
        • Task (1)
        • Setting (1)
      • C (19)
        • Concept (4)
        • Task (8)
        • Project (1)
        • Study (5)
        • Setting (1)
      • C++ (1)
        • Study (0)
        • Concept (1)
      • Python (6)
        • Task (4)
        • Project (2)
      • 일상 (1)
      • Setting (1)
      • 홍보 (1)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    #광주인력개발원#대한상공회의소#상공회의소#인력개발원#청년#일경험#ESG#청년일경험&#160;#오텍캐리어#수당100만원#광주#구직단념#그린#Green#취준생#이력서#취업준비#취업맛집&#160;#취업우수기관#국비교육#대학생#ESG지원형
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
eull
6/3_Python PC방 키오스크 제작
상단으로

티스토리툴바