Ejemplo n.º 1
0
 def move_to_next_cell(x: int = 1, y: int = 1) -> list:
     nonlocal solved
     if solved:
         solved = False
         moves.clear()
     current_cell = int(f'{x}{y}')
     moves.append(current_cell)
     next_cell = board[x - 1][y - 1]
     if next_cell == current_cell:
         solved = True
         return moves
     next_x, next_y = get_digit(next_cell, 1), get_digit(next_cell, 0)
     return move_to_next_cell(next_x, next_y)
Ejemplo n.º 2
0
 def _get_choices(self, order):
     """
     getting choices of dishes
     :param order: Order
     :return: Order
     """
     print(f"Hello, I'm {self.name}. What would you like to eat?")
     while True:
         print(self._catering.menu)
         print('enter "0" for end ordering')
         dish_number = get_digit(len(self._catering.menu.items))
         if not dish_number:
             break
         dish = self._catering.menu.items[dish_number]
         quantity = get_digit(MAX_ORDER_ITEM_COUNT, COUNT_REQUEST)
         if not quantity:
             quantity = 1
         order.add_dish(dish, quantity)
     return order
Ejemplo n.º 3
0
    def get_order(self, this_customer):
        """
        Getting order
        :param this_customer: Customer
        :return:
        """
        order = Order(waiter=self, customer=this_customer)
        while True:
            order = self._get_choices(order)
            print('your order:')
            table = PrettyTable()
            table.field_names = ['Order']
            for item in order.items:
                table.add_row([str(item)])
            print(str(table))

            if get_digit(1, 'Enter 1 to confirm or 0 to cancel: '):
                self._orders_dict[this_customer.table] = order
                this_customer.set_check_list(order.items)
                order.change_status()
                break
            order.items.clear()
        order.change_status()
        self._catering.get_order(order)
Ejemplo n.º 4
0
 def hint_coordinates(self):
     if isinstance(self.hint, str) and len(self.hint) == 2:
         return int(self.hint[0]), int(self.hint[1])
     return get_digit(self.hint, 1), get_digit(self.hint, 0)
Ejemplo n.º 5
0
 def clue_coordinates(self) -> tuple:
     if isinstance(self.clue, str) and len(self.clue) == 2:
         return int(self.clue[0]), int(self.clue[1])
     return get_digit(self.clue, 1), get_digit(self.clue, 0)
Ejemplo n.º 6
0
def test_get_ndigit():
    number = 15
    assert get_digit(number, 1) == 1
    assert get_digit(number, 0) == 5