Exemple #1
0
class Person:
    def __init__(self, money):
        self.common = CommonFunc()
        self.money = self.common.values_chk(money)
        self.place = None

    def sub_menu(self):
        print("무엇을 할까~~")
        for i in MainMenu:
            print("{}. {}".format(i.value, i.name), end='\t')
        print("")

        choice = input("입력: ")
        c2 = self.common.values_chk(choice)
        if c2 == MainMenu.HOME.value:
            self.go_home()
        elif c2 == MainMenu.LOTTO.value:
            if self.min_money(LOTTO_MIN):
                input("돈 없어. 집에 가자 enter ->")
                self.go_home()
            else:
                self.go_lotto()
        elif c2 == MainMenu.BOWLING.value:
            if self.min_money(BOWLING_MIN):
                input("돈 없어. 집에 가자 enter ->")
                self.go_home()
            else:
                self.go_bowling()
        else:
            input("1~3 중 선택하세요 enter ->")
            return self.sub_menu()

        self.go()

    def min_money(self, min_money):
        return self.money < min_money

    def go(self):
        if self.place:
            self.place.sub_menu()
        else:
            print("Error!")

    def go_home(self):
        self.place = Home(self)

    def go_lotto(self):
        self.place = Lotto(self)

    def go_bowling(self):
        self.place = Bowling(self)
Exemple #2
0
    def chk_kinds(self, num):
        print("1. 자동    2. 수동   3. 뒤로가기")
        choice = input(INPUT_TEXT)
        c2 = CommonFunc.values_chk(choice)
        if 0 < c2 < 4:
            if c2 == 1:
                for i in range(num):
                    self.buy_auto()
                    print("{}번째 {}".format(i + 1,
                                           self.user_lottos[self.l_index - 1]))
                self.money = CommonFunc.left_money(self.money, num * ONE_PRICE,
                                                   False)
                print("남은 돈: {}".format(self.money))

                self.again()
            elif c2 == 2:
                for i in range(num):
                    self.buy_manual()
                    print("{}번째 {}".format(i + 1,
                                           self.user_lottos[self.l_index - 1]))
                self.money = CommonFunc.left_money(self.money, num * ONE_PRICE,
                                                   False)
                print("남은 돈: {}".format(self.money))

                self.again()
            if c2 == 3:
                self.sub_menu()
        else:
            print("1~3 사이의 번호를 입력하세요.")
            self.chk_kinds(num)
Exemple #3
0
 def sub_menu(self):
     print("로또사러 왔다.")
     for i in LottoMenu:
         print("{}. {}".format(i.value, i.name), end="\t")
     print("")
     choice = input(INPUT_TEXT)
     c2 = CommonFunc.values_chk(choice)
     if c2 == LottoMenu.Buy_Lotto.value:
         print("로또구매")
         self.buy_lotto()
     elif c2 == LottoMenu.Check_Win.value:
         print("=" * 25)
         print("당첨확인")
         print("=" * 25)
         if not self.user_lottos:
             input("구매한 로또가 없습니다.\n사러가기 enter ->")
             self.buy_lotto()
         else:
             print("현재 {}장 있습니다.".format(len(self.user_lottos)))
             self.chk_win()
     elif c2 == LottoMenu.Next_Lotto.value:
         print("회차넘김")
         self.next_lotto()
     elif c2 == LottoMenu.H**o.value:
         self.person.go_home()
         self.person.go()
     else:
         input("1~4 중 선택하세요 enter ->")
         self.sub_menu()
Exemple #4
0
    def buy_lotto(self):
        if len(self.user_lottos) >= MAX_BUY:
            input("최대 30만원까지 구매 가능합니다 enter ->")
            self.sub_menu()
        elif self.min_money():
            print("남은 돈: {}".format(self.money))
            input("돈이 부족합니다. enter ->")
            self.sub_menu()
        else:
            print("몇 장 구매하시겠습니까? (최대 20장 가능)")
            count = input("개수: ")
            c2 = CommonFunc.values_chk(count)
            if len(self.user_lottos) + c2 > MAX_BUY:
                print("최대 30만원까지 구매 가능합니다.")
                print("현재 구매 가능한 개수는 {}입니다.".format(MAX_BUY -
                                                    len(self.user_lottos)))
                self.buy_lotto()
            elif c2 * ONE_PRICE > self.money:
                print("돈이 부족합니다.")
                print("남은 돈: {}".format(self.money))
                input()
                self.sub_menu()

            if 0 < c2 < 21:
                self.chk_kinds(c2)
            else:
                print("최소 1장, 최대 20장이어야 합니다.")
                self.buy_lotto()
Exemple #5
0
 def win_chk_again(self):
     print("다시 확인하시겠습니까? 1. 네    2. 아니오")
     choice = input(INPUT_TEXT)
     c2 = CommonFunc.values_chk(choice)
     if c2 == 1:
         self.chk_win()
     elif c2 == 2:
         self.sub_menu()
     else:
         print("1 또는 2만 입력하세요.")
         self.win_chk_again()
Exemple #6
0
 def again(self):
     print("계속 구매하시겠습니까? 1. 네    2. 메인으로")
     choice = input(INPUT_TEXT)
     c2 = CommonFunc.values_chk(choice)
     if 0 < c2 < 3:
         if c2 == 1:
             self.buy_lotto()
         else:
             self.sub_menu()
     else:
         input("1 또는 2만 입력하세요 enter ->")
         self.again()
Exemple #7
0
 def again(self):
     """다시하기 메뉴"""
     print("1. 메인으로 2. 집으로")
     choice = input("입력: ")
     c2 = CommonFunc.values_chk(choice)
     if c2 == 1:
         self.sub_menu()
     elif c2 == 2:
         self.person.go_home()
         self.person.go()
     else:
         print("1~2 사이 수만 입력하세요.")
         self.again()
Exemple #8
0
 def next_lotto(self):
     print("다음 회차로 넘기시겠습니까? 1. 네    2. 아니오")
     choice = input(INPUT_TEXT)
     c2 = CommonFunc.values_chk(choice)
     if c2 == 1:
         self.win_nums = []
         self.user_lottos = {}
         self.sub_menu()
     elif c2 == 2:
         self.sub_menu()
     else:
         print("1 또는 2만 입력하세요.")
         self.next_lotto()
Exemple #9
0
 def buy_manual(self):
     nums = []
     for i in range(1, 7):
         while True:
             print("{}번째 수 입력: ".format(i))
             num = input()
             n2 = CommonFunc.values_chk(num)
             if n2 not in range(1, 46):
                 print("1~45 사이의 수만 입력하세요.")
                 continue
             if n2 in nums:
                 x = nums.index(n2) + 1
                 print("{}번째 수와 중복입니다.".format(x))
                 continue
             nums.append(n2)
             nums.sort()
             break
     self.user_lottos[self.l_index] = nums
     self.l_index += 1
Exemple #10
0
    def sub_menu(self):
        print("집 도착!")
        for i in HomeMenu:
            print("{}. {}".format(i.value, i.name))
        choice = input("입력: ")
        c2 = CommonFunc.values_chk(choice)

        if c2 == HomeMenu.Lotto.value:
            self.person.go_lotto()
            self.person.go()
        elif c2 == HomeMenu.Bowling.value:
            self.person.go_bowling()
            self.person.go()
        elif c2 == HomeMenu.Go_Outside.value:
            self.person.sub_menu()
        elif c2 == HomeMenu.Exit.value:
            print("빠잉~!")
            pass
        else:
            print("1~4 사이의 수만 입력하세요.")
            self.sub_menu()
Exemple #11
0
 def sub_menu(self):
     """Bowling class main_menu"""
     print("볼링치러 왔다.")
     for i in BowlingMenu:
         print("{}. {}".format(i.value, i.name))
     choice = input("입력: ")
     c2 = CommonFunc.values_chk(choice)
     if c2 == BowlingMenu.Bowling.value:
         if self.min_money():
             print("남은 돈: {}".format(self.money))
             input("돈이 부족합니다.")
             self.sub_menu()
         else:
             self.total_score()
     elif c2 == BowlingMenu.Check_Score.value:
         self.show_last_score()
     elif c2 == BowlingMenu.Home.value:
         self.person.go_home()
         self.person.go()
     else:
         print("1~3 사이의 수만 입력하세요.")
         self.sub_menu()
Exemple #12
0
from common_func import CommonFunc
from person import Person

if __name__ == "__main__":
    user_money = input("지금 돈 얼마 있어?\n입력: ")
    user_money = CommonFunc.values_chk(user_money)

    person = Person(user_money)
    person.sub_menu()