|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": 1, |
| 6 | + "metadata": {}, |
| 7 | + "outputs": [ |
| 8 | + { |
| 9 | + "data": { |
| 10 | + "text/plain": [ |
| 11 | + "<Order total: 42.00 due: 39.90>" |
| 12 | + ] |
| 13 | + }, |
| 14 | + "execution_count": 1, |
| 15 | + "metadata": {}, |
| 16 | + "output_type": "execute_result" |
| 17 | + } |
| 18 | + ], |
| 19 | + "source": [ |
| 20 | + "from ex_6_3__functional_strategy import (\n", |
| 21 | + " Customer,\n", |
| 22 | + " LineItem,\n", |
| 23 | + " Order,\n", |
| 24 | + " fidelity_promo,\n", |
| 25 | + " bulk_item_promo,\n", |
| 26 | + " large_order_promo,\n", |
| 27 | + ")\n", |
| 28 | + "joe = Customer('John Doe', 0)\n", |
| 29 | + "ann = Customer('Ann Smith', 1100)\n", |
| 30 | + "cart = [\n", |
| 31 | + " LineItem('banana', 4, .5),\n", |
| 32 | + " LineItem('apple', 10, 1.5),\n", |
| 33 | + " LineItem('watermellon', 5, 5.0),\n", |
| 34 | + "]\n", |
| 35 | + "Order(joe, cart, fidelity_promo)\n" |
| 36 | + ] |
| 37 | + }, |
| 38 | + { |
| 39 | + "cell_type": "code", |
| 40 | + "execution_count": 2, |
| 41 | + "metadata": {}, |
| 42 | + "outputs": [ |
| 43 | + { |
| 44 | + "data": { |
| 45 | + "text/plain": [ |
| 46 | + "<Order total: 42.00 due: 39.90>" |
| 47 | + ] |
| 48 | + }, |
| 49 | + "execution_count": 2, |
| 50 | + "metadata": {}, |
| 51 | + "output_type": "execute_result" |
| 52 | + } |
| 53 | + ], |
| 54 | + "source": [ |
| 55 | + "Order(ann, cart, fidelity_promo)" |
| 56 | + ] |
| 57 | + }, |
| 58 | + { |
| 59 | + "cell_type": "code", |
| 60 | + "execution_count": 3, |
| 61 | + "metadata": {}, |
| 62 | + "outputs": [ |
| 63 | + { |
| 64 | + "data": { |
| 65 | + "text/plain": [ |
| 66 | + "<Order total: 30.00 due: 28.50>" |
| 67 | + ] |
| 68 | + }, |
| 69 | + "execution_count": 3, |
| 70 | + "metadata": {}, |
| 71 | + "output_type": "execute_result" |
| 72 | + } |
| 73 | + ], |
| 74 | + "source": [ |
| 75 | + "banana_cart = [\n", |
| 76 | + " LineItem('banana', 30, .5),\n", |
| 77 | + " LineItem('apple', 10, 1.5),\n", |
| 78 | + "]\n", |
| 79 | + "Order(joe, banana_cart, bulk_item_promo)" |
| 80 | + ] |
| 81 | + }, |
| 82 | + { |
| 83 | + "cell_type": "code", |
| 84 | + "execution_count": 4, |
| 85 | + "metadata": {}, |
| 86 | + "outputs": [ |
| 87 | + { |
| 88 | + "ename": "NameError", |
| 89 | + "evalue": "name 'large_order_promo' is not defined", |
| 90 | + "output_type": "error", |
| 91 | + "traceback": [ |
| 92 | + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
| 93 | + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", |
| 94 | + "\u001b[0;32m<ipython-input-4-80e58dad44d7>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mitem_code\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m10\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m ]\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0mOrder\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mjoe\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlong_order\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlarge_order_promo\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", |
| 95 | + "\u001b[0;31mNameError\u001b[0m: name 'large_order_promo' is not defined" |
| 96 | + ] |
| 97 | + } |
| 98 | + ], |
| 99 | + "source": [ |
| 100 | + "long_order = [\n", |
| 101 | + " LineItem(str(item_code), 1, 1.0)\n", |
| 102 | + " for item_code in range(10)\n", |
| 103 | + "]\n", |
| 104 | + "Order(joe, long_order, large_order_promo)" |
| 105 | + ] |
| 106 | + }, |
| 107 | + { |
| 108 | + "cell_type": "code", |
| 109 | + "execution_count": null, |
| 110 | + "metadata": {}, |
| 111 | + "outputs": [], |
| 112 | + "source": [] |
| 113 | + } |
| 114 | + ], |
| 115 | + "metadata": { |
| 116 | + "interpreter": { |
| 117 | + "hash": "916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1" |
| 118 | + }, |
| 119 | + "kernelspec": { |
| 120 | + "display_name": "Python 3.8.10 64-bit", |
| 121 | + "language": "python", |
| 122 | + "name": "python3" |
| 123 | + }, |
| 124 | + "language_info": { |
| 125 | + "codemirror_mode": { |
| 126 | + "name": "ipython", |
| 127 | + "version": 3 |
| 128 | + }, |
| 129 | + "file_extension": ".py", |
| 130 | + "mimetype": "text/x-python", |
| 131 | + "name": "python", |
| 132 | + "nbconvert_exporter": "python", |
| 133 | + "pygments_lexer": "ipython3", |
| 134 | + "version": "3.8.10" |
| 135 | + }, |
| 136 | + "orig_nbformat": 4 |
| 137 | + }, |
| 138 | + "nbformat": 4, |
| 139 | + "nbformat_minor": 2 |
| 140 | +} |
0 commit comments