def run_homework(): order_elements = generate_order_elements(11) five_percent_discount = PercentageDiscount(discount_percentage=5) hundred_pln_discount = AbsoluteDiscount(discount_value=100) order = Order(client_first_name="Maciej", client_last_name="Xyz", order_elements=order_elements) order_5_percent = Order(client_first_name="Maciej", client_last_name="Xyz", order_elements=order_elements, discount_policy=five_percent_discount) order_100 = Order(client_first_name="Maciej", client_last_name="Xyz", order_elements=order_elements, discount_policy=hundred_pln_discount) express_order = ExpressOrder(delivery_date="20th December 2020", client_first_name="Maciej", client_last_name="Sobieszuk", order_elements=order_elements) express_order_discount = ExpressOrder(delivery_date="20th December 2020", client_first_name="Maciej", client_last_name="Sobieszuk", order_elements=order_elements, discount_policy=hundred_pln_discount) print(order) print(order_5_percent) print(order_100) print(express_order) print(express_order_discount)
def run_homework(): order_elements = data_generator.generate_order_elements() ten_percent_discount = PercentageDiscount(discount_percentage=10) hundred_pln_discount = AbsoluteDiscount(discount_value=100) no_discount_order = Order( client_first_name="M", client_last_name="L", order_elements=order_elements, ) order_with_percentage_discount = Order( client_first_name="M", client_last_name="L", order_elements=order_elements, discount_policy=ten_percent_discount, ) order_with_absolute_value_discount = Order( client_first_name="M", client_last_name="L", order_elements=order_elements, discount_policy=hundred_pln_discount, ) print(no_discount_order) print(order_with_percentage_discount) print(order_with_absolute_value_discount)
def run_homework(): product_one = Product(name="Cookies", category_name="Food", unit_price=3.5) product_two = Product(name="Cheese", category_name="Food", unit_price=3.5) product_three = Product(name="Cookies", category_name="Food", unit_price=3.5) print(f"Products 1 and 2 are equal? {product_one == product_two}") print(f"Products 1 and 3 are equal? {product_one == product_three}") print(f"Products 2 and 3 are equal? {product_two == product_three}") order_element_1 = OrderElement(product_one, 3) order_element_2 = OrderElement(product_one, 3) order_element_3 = OrderElement(product_two, 4) print( f"Order elements 1 and 2 are equal? {order_element_1 == order_element_2}" ) print( f"Order elements 1 and 3 are equal? {order_element_1 == order_element_3}" ) print( f"Order elements 2 and 3 are equal? {order_element_2 == order_element_3}" ) order_1 = Order(client_first_name="Maciej", client_last_name="Sobieszuk", order_elements=[order_element_1, order_element_2]) order_2 = Order(client_first_name="Maciej", client_last_name="Sobieszuk", order_elements=[order_element_2, order_element_1]) order_3 = Order(client_first_name="Maciej", client_last_name="Xyz", order_elements=[order_element_1, order_element_2]) print(f"Orders 1 and 2 are equal? {order_1 == order_2}") print(f"Orders 1 and 3 are equal? {order_1 == order_3}") print(f"Orders 2 and 3 are equal? {order_2 == order_3}")
def run_homework(): cookie = Product(name="Ciastko", category_name="Jedzenie", unit_price=4) # other_cookie = Product(name="Inne ciastko", category_name="Jedzenie", unit_price=4) juice = Product(name="Sok", category_name="Napoje", unit_price=3) first_order_elements = [ OrderElement(product=cookie, quantity=3), # OrderElement(product=other_cookie, quantity=3), OrderElement(product=juice, quantity=4), ] # first_order_elements.append(OrderElement(product=juice, quantity=4)) # first_order_elements[0].quantity = 10 second_order_elements = [ OrderElement(product=juice, quantity=4), OrderElement(product=cookie, quantity=3), ] first_order = Order(client_first_name="Kuba", client_last_name="Kowalski", order_elements=first_order_elements) second_order = Order(client_first_name="Kuba", client_last_name="Kowalski", order_elements=second_order_elements) # second_order.client_last_name = "Lewandowski" if first_order == second_order: print("Te zamówienia są takie same!") else: print("Te zamówienia są różne!")
def run_example(): order_elements = data_generator.generate_order_elements(6) order_1 = Order("Mac", "XYz", order_elements) print(order_1) product = data_generator.generate_product() quantity = data_generator.generate_quantity() order_1.add_product_to_order(product, quantity) print(order_1)
def run_homework(): order_over_limit = Order.generate_order(10) print(order_over_limit) cookie = Product(name="Ciastko", category_name="Jedzenie", unit_price=4) order_below_limit = Order.generate_order(4) order_below_limit.add_product_to_order(cookie, quantity=10) print(order_below_limit) order_over_limit.add_product_to_order(cookie, quantity=10) print(order_over_limit)
def run_homework(): order_elements_on_limit = data_generator.generate_order_elements( products_to_generate=Order.MAX_ELEMENTS) order_on_limit = Order("Bob", "Kowalski", order_elements=order_elements_on_limit) product = data_generator.generate_product() quantity = data_generator.generate_quantity() order_on_limit.add_product_to_order(product, quantity)
def run_homework(): order_elements = data_generator.generate_order_elements(Order.MAX_ELEMENTS) order_on_limit = Order("Mariusz", "Baran", order_elements) product = data_generator.generate_product() quantity = data_generator.generate_quantity() try: order_on_limit.add_product_to_order(product, quantity) except ElementsInOrderLimitError as error: print(f"{error}, dostępna ilość: {error.allowed_limit}")
def run_homework(): order_elements_on_limit = data_generator.generate_order_elements(products_to_generate=Order.MAX_ELEMENTS) order_on_limit = Order("Bob", "Kowalski", order_elements=order_elements_on_limit) product = data_generator.generate_product() quantity = data_generator.generate_quantity() try: order_on_limit.add_product_to_order(product, quantity) except ElementsInOrderLimitError as error: print(f"Wystąpił błąd: {error}") print(f"Limit pozycji w zamówieniu wynosi: {error.allowed_limit}")
def run_homework(): first_order = Order.generate_order(10) print(first_order) second_order = Order.generate_order(2) print(second_order) cookies = Product(name="Cookies", category_name="Food", unit_price=5) first_order.add_product_to_order(cookies, quantity=1) print(first_order) second_order.add_product_to_order(cookies, quantity=10) print(second_order) second_order.add_product_to_order(cookies, quantity=5) print(second_order)
def run_homework(): order_elements = generate_order_elements() normal_order = Order(client_first_name="Maciej", client_last_name="Xyz", order_elements=order_elements) print(normal_order) order_elements_2 = generate_order_elements(3) normal_order.order_elements = order_elements_2 print(normal_order) order_elements_3 = generate_order_elements(1000) normal_order.order_elements = order_elements_3 print(normal_order)
def run_homework(): order_elements_on_limit = data_generator.generate_order_elements( products_to_generate=Order.MAX_ELEMENTS) order_on_limit = Order("Bob", "Kowalski", order_elements=order_elements_on_limit) product = data_generator.generate_product() quantity = data_generator.generate_quantity() try: order_on_limit.add_product_to_order(product, quantity) except ElementsInOrderLimitError: print("Nie można dodać już nic więcej!")
def run_example(): order_elements = data_generator.generate_order_elements( number_of_products=Order.MAX_ORDER_ELEMENTS) order_1 = Order("Mac", "XYz", order_elements) print(order_1) product = data_generator.generate_product() quantity = data_generator.generate_quantity() try: order_1.add_product_to_order(product, quantity) except OrderElementsLimitError as error: print(f"Przekroczono limit!!!. ENG: {error}.") print(order_1)
def run_homework(): first_name = "Mikołaj" last_name = "Lewandowski" order_elements = generate_order_elements() normal_order = Order(first_name, last_name, order_elements) print(normal_order) new_elements = generate_order_elements(3) normal_order.order_elements = new_elements print(normal_order) too_many_elements = generate_order_elements(1000) normal_order.order_elements = too_many_elements print(normal_order)
def run_example(): order_elements = data_generator.generate_order_elements(number_of_products=Order.MAX_ORDER_ELEMENTS) order_1 = Order("Mac", "XYz", order_elements) print(order_1) product = data_generator.generate_product() quantity = data_generator.generate_quantity() try: order_1.add_product_to_order(product, quantity) except OrderElementsLimitError as error: print(f"Wystąpił błąd: >>{error}<<") print(f"Limit pozycji w zamówieniu wynosi: >>{error.places_limit}<<.") print(order_1)
def run_homework(): first_name = "Mikołaj" last_name = "Lewandowski" order_elements = generate_order_elements() normal_order = Order(first_name, last_name, order_elements) print(normal_order)
def load_orders(client_first_name, client_last_name, file_name="orders.json"): try: with open(file_name, "r") as orders_file: orders_by_clients_data = json.load(orders_file).get("orders", {}) except FileNotFoundError: orders_by_clients_data = {} client_id = f"{client_first_name}-{client_last_name}" if client_id not in orders_by_clients_data: return [] orders = orders_by_clients_data[client_id] return [ Order( client_first_name=order["client_first_name"], client_last_name=order["client_last_name"], order_elements=[ OrderElement( quantity=order_element["quantity"], product=Product( name=order_element["product"]["name"], category=ProductCategory[order_element["product"] ["category"]], unit_price=order_element["product"]["unit_price"], identifier=order_element["product"]["identifier"], )) for order_element in order["order_elements"] ], ) for order in orders ]
def run_homework(): order_elements = generate_order(5) normal_order = Order(client_first_name="Maciej", client_last_name="Xyz", order_elements=order_elements) loyal_customer_order = Order(client_first_name="Maciej", client_last_name="Xyz", order_elements=order_elements, discount_policy=loyal_customer_policy) christmas_order = Order(client_first_name="Maciej", client_last_name="Xyz", order_elements=order_elements, discount_policy=christmas_policy) print(normal_order) print(loyal_customer_order) print(christmas_order)
def run_homework(): orders = [] for _ in range(5): orders.append(Order.generate_order()) orders.sort(key=get_order_price) for order in orders: print(order)
def run_homework(): first_name = "Mikołaj" last_name = "Lewandowski" order_elements = generate_order_elements() normal_order = Order(first_name, last_name, order_elements) loyal_customer_order = Order(first_name, last_name, order_elements, discount_policy=loyal_customer_policy) christmas_order = Order(first_name, last_name, order_elements, discount_policy=christmas_policy) print(normal_order) print(loyal_customer_order) print(christmas_order)
def run_homework(): orders = [] for i in range(5): orders.append(Order.generate_order()) orders.sort(key=lambda order: order.total_price) for order in orders: print(order)
def run(): # order_elements_on_limit = generate_order_elements(products_to_generate=Order.MAX_ELEMENTS) # order_on_limit = Order("Mariusz", "Baran", order_elements=order_elements_on_limit) # print(order_on_limit) # # product = generate_product() # quantity = generate_quantity() # order_on_limit.add_product_to_order(product, quantity) order_elements_over_limit = generate_order_elements(products_to_generate=Order.MAX_ELEMENTS + 1) order_over_limit = Order("Mariusz", "Baran", order_elements=order_elements_over_limit) print(order_over_limit)
def run_homework(): order = generate_order_elements() express_order = ExpressOrder(delivery_date="20th December 2020", client_first_name="Maciej", client_last_name="Sobieszuk", order_elements=order) christmas_order = Order(client_first_name="Maciej", client_last_name="Xyz", order_elements=order, discount_policy=christmas_policy) print(express_order) print(christmas_order)
def run(): order_elements = generate_order_elements() my_order = Order("Mariusz", "Baran", order_elements) print(my_order)
def run_homework(): some_order_elements = data_generator.generate_order_elements() my_order = Order("Bob", "Kowalski", order_elements=some_order_elements) print(my_order)
def run_homework(): order_products = generate_order_elements() order = Order("Mac", "XYZ", order_products) print(order)
def init_order(): first_name = input("Podaj imię: ") last_name = input("Podaj nazwisko: ") return Order(first_name, last_name)
def init_order(): first_name = input("Podaj swoje imię.") last_name = input("Podaj swoje nazwisko.") return Order(first_name, last_name)
def init_order(): first_name = input("Jak masz na imię? ") last_name = input("Jakie jest Twoje nazwisko? ") return Order(first_name, last_name)