def main(): # Create sale items. pants = retailitem.RetailItem('Pants', 10, 19.99) shirt = retailitem.RetailItem('Shirt', 15, 12.50) dress = retailitem.RetailItem('Dress', 3, 79.00) socks = retailitem.RetailItem('Socks', 50, 1.00) sweater = retailitem.RetailItem('Sweater', 5, 49.99) # Create dictionary of sale items. sale_items = {PANTS:pants, SHIRT:shirt, DRESS:dress, SOCKS:socks, SWEATER:sweater} # Create a cash register. register = cashregister.CashRegister() # Initialize loop test. checkout = 'N' # User wants to purchase more items: while checkout == 'N': user_choice = get_user_choice() item = sale_items[user_choice] ''' #If the item's iventory is 0 type 'The item is out of stock.' Otherwise, 1) add the item to the register 2) change the inventory number of the item in the sale_items dictionary 3) ask the user if they're ready to checkout Y/N and save that in the checkout var ''' #Your code here if item.UnitsinInventory == 0: print("") print("The item is out of stock.") print("") else: item.UnitsinInventory -= 1 register.Item_List = register.purchase_item(item) checkout = input("Are you ready to checkout (Y/N)? ") print("") print() print('Your purchase total is: ', \ format(register.get_total(), '.2f')) print() register.show_items() register.clear()
def main(): desc = "Hello" units = "5" price = 60 r_i = retailitem.RetailItem(desc, units, price) r_2 = retailitem.RetailItem(desc, units, price) #print(r_i) c_r = CashRegister() c_r.purchase_item(r_2) c_r.purchase_item(r_i) print(c_r.get_total()) print(c_r.show_items()) c_r.clear() print(c_r.show_items())
def main(): item1 = retailitem.RetailItem("Jelly Beans", 200000, 1.00) item2 = retailitem.RetailItem("Snickers", 100000, 1.50) item3 = retailitem.RetailItem("York Patties", 300000000, 0.50) items = [item1, item2, item3] register = cashregister.CashRegister() cont = "y" while cont == "y": print("\n-----------Items available to purchase:---------\n") count = 1 for item in items: print("Item (" + str(count) + ")") print(item) count += 1 try: item_choice = int(input("Pick an item to purchase: ")) if item_choice == 1: register.purchase_item(item1) elif item_choice == 2: register.purchase_item(item2) elif item_choice == 3: register.purchase_item(item3) else: raise Exception except: print("\nInvalid choice. Try again.") continue cont = input("\nPurchase more items (y/n)? ").lower() print("\n-----------Items selected to purchase:---------\n") register.show_items() print("Total is: $" + format(register.get_total(), ",.2f"))
def main(): import retailitem jacket = retailitem.RetailItem("Jacket", 12, 59.95) jeans = retailitem.RetailItem("Designer Jeans", 40, 34.95) shirt = retailitem.RetailItem("Shirt", 20, 24.95) jacket.Price = "%3.2f" % jacket.Price print("") print("Retail Item 1:") print("Description: " + jacket.Description) print("Units in inventory: " + str(jacket.UnitsinInventory)) print("Price: $" + jacket.Price) jeans.Price = "%3.2f" % jeans.Price print("") print("Retail Item 2:") print("Description: " + jeans.Description) print("Units in inventory: " + str(jeans.UnitsinInventory)) print("Price: $" + jeans.Price) shirt.Price = "%3.2f" % shirt.Price print("") print("Retail Item 3:") print("Description: " + shirt.Description) print("Units in inventory: " + str(shirt.UnitsinInventory)) print("Price: $" + shirt.Price) print("")
def main(): for _ in range(1, 4): product = input('Описание: ') quantity = input('Количество на складе: ') price = float(input('Цена: ')) print('-' * 61) print('|', ' ' * 8, '|', 'Описание', ' ' * 2, \ '|', 'Количество на складе', ' ' * 2, '|', \ 'Цена ', '|') print('-' * 61) my_retail = retailitem.RetailItem(product, quantity, price) print('|Товар №,', _, end='') print('|', my_retail.get_description(), " " * (11 - len(my_retail.get_description())), end='') print('|', my_retail.get_quantity(), ' ' * (23 - len(my_retail.get_quantity())), end='') print('|', my_retail.get_price(), '|') print('-' * 61)
# 5. RetailItem Class # Write a class named RetailItem that holds data about an item in a retail store. # The class should store the following data in attributes: item description, # units in inventory, and price. # Once you have written the class, write a program that creates three RetailItem # objects and stores the following data in them: # Description Units in Inventory Price # Item #1 Jacket 12 59.95 # Item #2 Designer Jeans 40 34.95 # Item #3 Shirt 20 24.95 import retailitem item1 = retailitem.RetailItem('Jacket',12,59.95) item2 = retailitem.RetailItem('Designer Jeans',40,34.95) item3 = retailitem.RetailItem('Shirt',20,24.95)
def main(): items = [] item1 = retailitem.RetailItem('Jacket', 12, 59.95) item2 = retailitem.RetailItem('Designer Jeans', 40, 34.95) item3 = retailitem.RetailItem('Shirt', 20, 24.95) items = [item1, item2, item3]