示例#1
0
    def __init__(self, cook_num: int):

        self.__cook_number = cook_num
        self.__cooks = [Cook() for _ in range(cook_num)]
        self.__food_cooking_time = {1: 30, 2: 20, 3: 10, 4: 15}
        self.__food_name = {1: "스테이크", 2: "스파게티", 3: "마카로니", 4: "그라탱"}
        self.__order_queue = []
示例#2
0
def main():

    # creation variables
    cook = Cook(COOK_SURNAME, COOK_NAME)
    government = Government()
    food = []
    panhandle_counter = 0

    # greeting
    print(GREETING_MESSAGE + cook.surname + " " + cook.name + "\n")

    # cooking food
    for i in range(AMOUNT_OF_DISHES):
        food.append(cook.cook_food())
    # the main action
    for i in range(AMOUNT_OF_CUSTOMERS):
        customer = Customer(random.choice(CUSTOMERS_SURNAMES), random.choice(CUSTOMERS_NAMES))
        print(str(customer) + "\n")


        while(customer.calorie_requirement > 0):

            print_menu(food)

            print(PURCHASE_CHOICE_MESSAGE)
            food_choice = input_num()
            if (check_element(food_choice)):
                continue

            if(customer.money >= food[food_choice - 1].cost):
                sell_food(food, food_choice, customer, cook)
                if(customer.health == 0):
                    customer.die()
                    break
            else:
                print(NOT_ENOUGH_MONEY)
                no_money_choice = input_num()
                if(no_money_choice == 1):
                    continue
                elif(no_money_choice == 21):
                    panhandle_action(panhandle_counter, customer, food)
                    if customer.health == 0 or customer.calorie_requirement > 0:
                        customer.die()
                        break
                else:
                    print("You have entered the invalid element!")
                    continue

        if not (customer.health == 0):
            print(THANKS_MESSAGE)

        if random.randint(1, 3) == 1:
            amount_of_seized = government.check_canteen(food, cook)
            if (amount_of_seized > 0):
                for i in range(amount_of_seized):
                    food.append(cook.cook_food())
            if cook.isBankrupt():
                break
    print("Amount of created food: " + str(Food.counter_food()))
示例#3
0
文件: test_cook.py 项目: khushu12/ck
 def setUp(self):
     self.o = Order({
         u'id': u'a8cfcb76-7f24-4420-a5ba-d46dd77bdffd',
         u'prepTime': 4,
         u'name': u'Banana Split'
     })
     cooking = MTList()
     cooking.put(self.o)
     self.c = Cook(MTList(), cooking)
示例#4
0
 def __init__(self, message):
     super().__init__(2, message)
     self.cook = Cook()
     self.category = None
示例#5
0
    print("***********************************************")
    select = get_int(0,4)
    return select


def get_int(min, max):
	x = int(input("Enter the numbers "))
	while x < min or x > max:
		x = int(input("Enter the numbers between {} and {} ".format(min, max)))
	return x

menu = get_menu()
while menu != 0:
    if menu == 1:
        os.system("cls")
        ck = Cook()
        check = ck.writeCus(0,1)
        os.system("pause")
    elif menu == 2:
        os.system("cls")
        ck = Cook()
        check = ck.writeCus(1,1)
        os.system("pause")
    elif menu == 3:
        os.system("cls")
        ck = Cook()
        check = ck.writeCus(2,1)
        os.system("pause")
    elif menu == 4:
        os.system("cls")
        ck = Cook()
示例#6
0
    def parse(self, path: str) -> None:
        """Parse the file and instantiate a configured Cook object.

        Parse critical data points from raw text and encapsulate them into
        a Cook object.

        Args:
            path: The file path to the cook data.
        """
        config = {}  # Cook attribute configuration
        # Obtain filename, product, and lot.
        file_name = path[path.rfind('\\') + 1:].strip()
        config["fname"] = file_name
        config["product"], config["lot"] = file_name.strip(".txt").split('_')

        with open(path, 'r') as f:
            text = f.readlines()
            # Obtain program, start time, and oven number.
            header = text[1].split(',')  # Isolate the report header
            config["program"] = header[1]
            start_info = header[3].replace('/', '-').strip()
            config["start_time"] = dt.strptime(start_info, "%m-%d-%Y %H:%M:%S")
            config["oven"] = text[2].split(',')[1][5:].strip()
            counter = dt.strptime("00:00", "%H:%M")
            curr_stage = 1
            stages = {}  # Add to config once all stage data is gathered

            # Iterate over the main text body.
            for this_line in text:
                if this_line.strip().endswith(",,"):  # Target cook data
                    line = this_line.split(',')

                    # Obtain starting temperatures.
                    if line[2] == "START":
                        config["start_temps"] = self._get_temps(line)
                    # Obtain final stage duration and ending temperatures.
                    elif line[2] == "END":
                        end_dur = self._get_stage(line, counter, curr_stage)[0]
                        stages[f"Stage {curr_stage}"] = end_dur
                        config["end_temps"] = self._get_temps(line)
                    # Obtain stage data.
                    elif int(line[2]) > curr_stage:
                        _ = self._get_stage(line, counter, curr_stage)
                        stages[f"Stage {curr_stage}"], counter, curr_stage = _

                # Obtain in and out weights.
                elif this_line.startswith("In-weight:"):
                    config["in_weight"] = self._get_weight(this_line)
                elif this_line.startswith("Out-weight:"):
                    config["out_weight"] = self._get_weight(this_line)
                else:
                    config["in_weight"], config["out_weight"] = -1, -1

                # TODO Parse Comments and Errors.
            config["comments"], config["errors"] = [], []

        # Configure the final Cook attributes.
        config["stages"] = stages
        duration = int(sum(stages.values()))
        config["duration"] = duration
        config["end_time"] = self._get_end_time(config["start_time"], duration)
        _yield = self._get_yield(config["in_weight"], config["out_weight"])
        config["cook_yield"] = _yield
        self._current_cook = Cook(config)  # Create the Cook object
示例#7
0
    def onMessage(self,
                  author_id=None,
                  message_object=None,
                  thread_id=None,
                  thread_type=ThreadType.USER,
                  **kwargs):
        self.markAsRead(author_id)  # mark read message
        log.info("Message {} from {} in {}".format(
            message_object, thread_id, thread_type))  # log message incoming
        self.apiaiCon()  # use ai function
        msgtext = message_object.text  # read message
        log.info(msgtext)  # log message
        if author_id != self.uid and thread_type == ThreadType.USER:
            self.request.query = msgtext  # throw message to dialogflow
            response = self.request.getresponse(
            )  # receive response from server
            obj = json.load(response)  # decode json to array
            log.info(obj)  # log object from server
            Action = obj['result']['action']  # access to action of bot
            reply = obj['result']['fulfillment'][
                'speech']  # access to reply bot
            if Action == "weather" or Action == "weather.temperature":
                Result = self.WeatherConnector(obj)
                if Result == 1:
                    self.send(Message(
                        text=
                        "Sorry, \nwe cannot collect data from the past or forecast more than 5 days"
                    ),
                              thread_id=thread_id,
                              thread_type=thread_type)
                    self.markAsDelivered(author_id, thread_id)
                else:
                    if Action == "weather":
                        self.send(
                            Message(text="There are {} in {} {}!!".format(
                                Result[0], Result[1], Result[2])),
                            thread_id=thread_id,
                            thread_type=thread_type)
                        self.markAsDelivered(author_id, thread_id)
                    else:
                        self.send(Message(
                            text="{} temperature is {} Celsius in {}!".format(
                                Result[2], Result[0], Result[1])),
                                  thread_id=thread_id,
                                  thread_type=thread_type)
                        self.markAsDelivered(author_id, thread_id)
            else:
                ckas = Cook()  # Create Cook object
                linkCk = ckas.start(msgtext, author_id)
                if linkCk == 1:
                    log.info("=====>" + author_id)
                    self.send(Message(text=reply),
                              thread_id=thread_id,
                              thread_type=thread_type)
                    self.markAsDelivered(author_id, thread_id)
                else:
                    log.info(linkCk)
                    self.send(Message(text=linkCk),
                              thread_id=thread_id,
                              thread_type=thread_type)
                    self.markAsDelivered(author_id, thread_id)

        elif author_id == self.uid and msgtext == "bot_shutdown":
            self.send(Message(text="Bot shutting down"),
                      thread_id=thread_id,
                      thread_type=thread_type)
            self.markAsDelivered(author_id, thread_id)
            self.logout()