Exemple #1
0
    def start(self, code):
        self.__code = code
        self.greet()
        print("{:^40}".format("Is it a takeout? y/n"))
        current_order = Order(self.__code, True) if input() == ("y" or "Y") else Order(self.__code)

        #Async request for pizzas
        available = []
        for pizza in asyncio.run(check_availability()):
            available.append(self.menu[pizza])

        while True:
            self.greet()
            print(current_order)
            print("\nChoose your pizza:")
            for p in range(len(available)):
                position = available[p]
                print("{} - ${:.2f} - {}".format(p+1, position.cost, position.title))
            print("Enter the id of pizza, or 0 to finish")
            chosen = int(input())

            if chosen in range(len(available)+1):
                if chosen == 0:
                    break
                chosen_pizza = available[chosen - 1]
                try:
                    current_order.add(chosen_pizza)
                except Exception as e:
                    print(e)
                    print("Press enter to continue to checkout...")
                    input()
                    break

                baking = threading.Thread(target=chosen_pizza.bake)
                packing = threading.Thread(target=chosen_pizza.pack, args=(current_order.takeout,))
                baking.start()
                packing.start()
            else:
                continue

            baking.join()
            packing.join()
            print("\n1 - Choose another\n0 - Finish the order")

            if input() == "1":
                continue
            else:
                break

        self.greet()
        print(current_order)
        print("Proceed to checkout...")
        print("You can pick up your order " + Handout.location_of_pickup)
        self.__code += 1
Exemple #2
0
    def get_new_order(self, lbm, ubm, fname):
        # only one product!
        for i, v in self.config.f_stocks[fname][
                constant.WType.products].items():
            iname = i
            base = v["base"]
        qty = random.randint(lbm, ubm) * base

        #supplier = self.get_factory(fname)
        r = ItemRecord(iname, qty)
        order = Order(fname)
        order.add(r)
        order.display()
        return order
Exemple #3
0
class OrderScreen(Screen):
    def __init__(self):
        pass

    def update_ui(self):
        self.current_order = Order(self.terminal.code, self.terminal.takeout)
        self.terminal.log_ui.configure(height="5", pady="20")
        self.terminal.window.geometry("480x640")
        self.terminal.status_text.set(self.current_order)
        self.terminal.main.config(text="Proceed to checkout", command=lambda: self.terminal.segue_to(CheckoutScreen()))
        self.terminal.secondary.config(text="Cancel the order", command=lambda: self.terminal.segue_to(CheckoutScreen()))
        self.update_pizza_list()

    def update_pizza_list(self):
        menu = MenuAdapter()
        available = menu.update()
        print(available)

        for widget in self.terminal.pizzas.winfo_children():
            widget.destroy()

        Label(self.terminal.pizzas, text="CHOOSE YOUR PIZZA", pady="3",
              font=("Helvetica", 16, "bold")).pack(pady="10")
        for pizza in available:
            pizza_button = Button(self.terminal.pizzas, command=lambda p=pizza: self.select_pizza(p),
                                  text="{} - ${}".format(pizza.title, pizza.cost),
                                  width="20", pady=10, font=("Helvetica", 20, "bold"))
            pizza_button.pack(pady="5")

    def select_pizza(self, pizza):
        try:
            self.current_order.add(pizza)

            if len(self.current_order.order_list) > 4:
                self.terminal.status_text.set(self.current_order.__str__() + "\n DISCOUNT 20%")
            else:
                self.terminal.status_text.set(self.current_order)

            self.update_log(pizza.bake())
            self.update_log("{} pizza is baked!".format(pizza.title))

            self.update_log(pizza.pack(self.terminal.takeout))
            self.update_log("{} pizza is packed!".format(pizza.title))

        except Exception as e:
            self.update_log(e.__str__())

    def update_log(self, message):
        self.terminal.log.write(message)
        self.terminal.log_text.set(self.terminal.log.history)
Exemple #4
0
    def start(self, code):
        self.__code = code
        self.greet()
        print("{:^40}".format("Is it a takeout? y/n"))
        current_order = Order(self.__code, True) if input() == (
            "y" or "Y") else Order(self.__code)

        while True:
            self.greet()
            print(current_order)
            print("\nChoose your pizza:")
            for p in range(len(self.menu)):
                position = self.menu[p]
                print("{} - ${:.2f} - {}".format(p + 1, position.cost,
                                                 position.title))
            print("Enter the id of pizza, or 0 to finish")
            chosen = int(input())

            if chosen in range(len(self.menu) + 1):
                if chosen == 0:
                    break
                chosen_pizza = self.menu[chosen - 1]
                current_order.add(chosen_pizza)
                chosen_pizza.bake()
                chosen_pizza.pack(current_order.takeout)
            else:
                continue

            print("\n1 - Choose another\n0 - Finish the order")

            if input() == "1":
                continue
            else:
                break

        self.greet()
        print(current_order)
        print("Proceed to checkout...")
        print("You can pick up your order " + Handout.location_of_pickup)  # !
        self.__code += 1
Exemple #5
0
def test():
    print('\n----product test----')
    product = Product('Bubble Tea', 'tea', 13.50)
    print(product)

    print('\n----shipping method test----')
    shippingMethod = ShippingMethod('FedEX', 'Faster and more expensive', 0.00,
                                    4.65)
    print(shippingMethod)

    print('\n----address test----')
    address = Address('1100 North 56th Street', 'Lincoln', 'NE', '68434')
    print(address)

    print('\n----line item test----')
    lineItem = LineItem(product, 3.5)
    print(lineItem)

    print('\n----order test 1----')
    order = Order(shippingMethod, address)
    print(order)
    order.add(product, 3.5)
    order.add(product, 1)
    print('\n----order test 2----')
    print(order)

    print('\n----customer test 1----')
    name = 'Lloyd Sommerer'
    customer = Customer(name, address)
    print(customer)
    customer.add(order)
    print('\n----customer test 2----')
    print(customer)

    print('\n----store test 1----')
    store = Store()
    print(store)
    store.add_customer(customer)
    print('\n----store test 2----')
    print(store)
    store.display()
    store.display(['mushrooms', 'coffee'])
    store.display('tea')

    print('\n----order test 3----')
    order.add(store.products[1], 10.5)
    order.add(store.products[2], 0.5)
    print(order)
Exemple #6
0
class Terminal:
    menu = {"Pepperoni": Pepperoni(), "BBQ": BBQ(), "Seafood": Seafood()}
    screen = 0
    log_history = ""

    def __init__(self):
        self.window = Tk()
        self.window.title("Pizza Time Terminal")
        self.window.geometry("480x240")
        self.window.configure()

        header = Label(self.window,
                       text="Welcome to Pizza Time!",
                       font=("Helvetica", 27, "bold"),
                       pady="20")

        self.status_text = StringVar()
        self.status_text.set("Is it a takeout?")
        status = Label(self.window,
                       textvariable=self.status_text,
                       font=("Helvetica", 20))

        self.pizzas = Frame(self.window)

        self.log_text = StringVar()
        self.log = Label(self.window,
                         textvariable=self.log_text,
                         font=("Helvetica", 16, "italic"),
                         fg="grey",
                         anchor="s")

        navbar = Frame(width="5")
        self.main = Button(navbar,
                           text="Yes",
                           command=lambda: self.set_current_order(True),
                           width="100",
                           font=("Helvetica", 20),
                           pady="10")
        self.secondary = Button(navbar,
                                text="No",
                                command=lambda: self.set_current_order(False),
                                width="100",
                                font=("Helvetica", 20),
                                pady="10")

        header.pack(side=TOP)
        status.pack(side=TOP)

        self.pizzas.pack(side=TOP)

        self.main.pack()
        self.secondary.pack()
        navbar.pack(side=BOTTOM)
        self.log.pack(side=BOTTOM)

    def update_status(self, message):
        self.status_text.set(message)

    def update_pizzas(self):
        available = []

        for pizza in asyncio.run(check_availability()):
            available.append(self.menu[pizza])

        for widget in self.pizzas.winfo_children():
            widget.destroy()

        Label(self.pizzas,
              text="CHOOSE YOUR PIZZA",
              pady="3",
              font=("Helvetica", 16, "bold")).pack(pady="10")
        for pizza in available:
            pizza_button = Button(self.pizzas,
                                  command=lambda p=pizza: self.select_pizza(p),
                                  text="{} - ${}".format(
                                      pizza.title, pizza.cost),
                                  width="20",
                                  pady=10,
                                  font=("Helvetica", 20, "bold"))
            pizza_button.pack(pady="5")

    def update_navbar(self):
        if self.screen == 1:
            self.window.geometry("480x640")
            self.update_pizzas()
            self.main.config(text="Proceed to checkout", command=self.checkout)
            self.secondary.config(text="Cancel the order", command=self.reset)
        if self.screen == 2:
            self.window.geometry("480x240")
            self.main.config(text="Create another order", command=self.reset)
            self.secondary.config(text="Exit the terminal",
                                  command=self.window.destroy)

    def set_current_order(self, takeout):
        self.current_order = Order(self.__code, takeout)
        self.screen = 1
        self.log.configure(height="5", pady="20")
        self.update_navbar()
        self.update_status(self.current_order)

    def select_pizza(self, pizza):
        try:
            self.current_order.add(pizza)

            if len(self.current_order.order_list) > 4:
                self.update_status(self.current_order.__str__() +
                                   "\n DISCOUNT 20%")
            else:
                self.update_status(self.current_order)

            packing = threading.Thread(target=pizza.pack,
                                       args=(self.current_order.takeout, ))
            baking = threading.Thread(target=pizza.bake)

            baking.start()
            packing.start()

            baking.join()
            self.update_log("{} pizza is baked!".format(pizza.title))
            packing.join()
            self.update_log("{} pizza is packed!".format(pizza.title))
        except Exception as e:
            self.update_log(e.__str__())

    def update_log(self, message):
        self.log_history += "\n" + message
        self.log_text.set(self.log_history)

    def start(self, code):
        self.__code = code
        self.window.mainloop()

    def checkout(self):
        self.screen = 2
        self.update_status(
            "Order #{} is ready.\nYou can pick up your order {}".format(
                self.__code, Handout.location_of_pickup))
        self.pizzas.destroy()
        self.log.destroy()
        self.update_navbar()
        self.__code += 1

    def reset(self):
        self.window.destroy()
        self.__init__()
        self.screen = 0
        self.log_history = ""