示例#1
0
 def update(self):
     if not self.waiting:
         return
     self.time -= 1
     if self.time < 0:
         self.time = 5
         Printer.add(f'{self.waiting.pop(0)}번 손님이 계산을 마치고 레스토랑을 떠났습니다.')
示例#2
0
    def new_customer(self):
        time = randrange(15, 41)
        if not self.__table.is_waitable(waitable_time=time,
                                        waiting_amount=len(self.waiting)):
            Printer.add(
                f'손님이 기다릴 수 없어 돌아갑니다. 현재대기시간 {self.__table.waitable_time}분 / 대기가능시간 {time}분'
            )
            return

        self.__customer_number += 1
        self.waiting.append(self.__customer_number)
        Printer.add(
            f'{self.__customer_number}번째 손님이 시각 {self.time}분에 레스토랑에 도착했습니다.')
示例#3
0
    def run(self):
        Printer.init()
        period = 2
        self.time = 1
        while self.time < 721:

            Printer.add(f'[현재시각 : {self.time}분]')
            is_remained = self.time % period

            if not is_remained:
                self.new_customer()
            self.update()
            Printer.output()
            self.time += 1
示例#4
0
    def update(self):
        finished_table = []
        for i in self.table.keys():
            if not self.table[i]:
                continue

            if self.table[i].update():
                customer_num = self.table[i].info.number
                self.table[i] = []
                finished_table.append(customer_num)
                Printer.add(f'{customer_num}번 손님이 식사를 마쳤습니다. {customer_num}번 손님이 계산대 앞에 줄을 섭니다.')
        self.__bill.add(finished_table)
        self.__bill.update()
        return finished_table
示例#5
0
    def update(self):
        self.__table.update()
        self.__cook.update()

        sittable = self.__table.empty()
        while self.waiting and sittable:
            table_num, food_num = sittable.pop(0), randrange(1, 5)
            info = CustomerInfo(self.waiting.pop(0), table_num, food_num)
            cooking_time = self.cooking_time[food_num]

            total_time = self.__cook.waiting_time(
            ) + self.eating_time[food_num] + cooking_time
            self.__cook.order_time.append(cooking_time)
            self.__table.table[table_num] = Customer(
                info, self.eating_time[food_num], total_time)

            Printer.add(
                f'{info[0]}번 손님이 {info[1]}번 테이블에 앉습니다. {info[2]}번 요리({self.food_name[info[2]]})를 주문합니다.'
            )
示例#6
0
 def __change_status(self):
     self.__eating = not self.__eating
     print(self.info)
     Printer.add(
         f'{self.info.number}번 손님의 {self.info.food}번 요리({FOOD_NAME[self.info.food]}) 조리가 끝났습니다.'
         f'{self.info.number}번 손님이 식사를 시작합니다.')