def add_new_item(): """ This method adds the item to the dictionary and print the message to the user. """ item_code = input("Enter item code: ") item_description = input("Enter item description: ") item_rental_price = input("Enter item rental price: ") # Get price from the market prices module item_price = market_prices.get_latest_price() #default value is_furniture = input("Is this item a piece of furniture? (Y/N): ") if is_furniture.lower() == "y": item_material = input("Enter item material: ") item_size = input("Enter item size (S,M,L,XL): ") new_item = furniture_class.Furniture(item_code, item_description, item_price, item_rental_price, item_material, item_size) else: is_electric_appliance = input( "Is this item an electric appliance? (Y/N): ") if is_electric_appliance.lower() == "y": item_brand = input("Enter item brand: ") item_voltage = input("Enter item voltage: ") new_item = electric_appliances_class.ElectricAppliances( item_code, item_description, item_price, item_rental_price, item_brand, item_voltage) else: new_item = inventory_class.Inventory(item_code, item_description, item_price, item_rental_price) FULL_INVENTORY[item_code] = new_item.return_as_dictionary() print("New inventory item added")
def add_new_item(): """ add new item to FULL_INVENTORY """ global FULL_INVENTORY item_code = input("Enter item code: ") item_description = input("Enter item description: ") item_rental_price = input("Enter item rental price: ") item_price = market_prices.get_latest_price(item_code) is_furniture = input("Is this item a piece of furniture? (Y/N): ") if is_furniture.lower() == "y": item_material = input("Enter item material: ") item_size = input("Enter item size (S,M,L,XL): ") new_item = furniture_class.Furniture(item_code, item_description, item_price, item_rental_price, item_material, item_size) else: is_electric_appliance = input("""Is this item an electric appliance? (Y/N): """) if is_electric_appliance.lower() == "y": item_brand = input("Enter item brand: ") item_voltage = input("Enter item voltage: ") new_item = \ electric_appliances_class.ElectricAppliances(item_code, item_description, item_price, item_rental_price, item_brand, item_voltage) else: new_item = inventory_class.Inventory(item_code, item_description, item_price, item_rental_price) FULL_INVENTORY[item_code] = new_item.return_as_dictionary() print("New inventory item added")
def add_new_item(): """gets information about a new item from user, then enters item into inventory""" code = input("Enter item code: ") description = input("Enter item description: ") rental_price = input("Enter item rental price: ") # Get price from the market prices module price = market_prices.get_latest_price(code) is_furniture = input("Is this item a piece of furniture? (Y/N): ") if is_furniture.lower() == "y": material = input("Enter item material: ") size = input("Enter item size (S,M,L,XL): ") new_item = furniture_class.Furniture(code, description, price, rental_price, material, size) else: is_electric_appliance = input( "Is this item an electric appliance? (Y/N): ") if is_electric_appliance.lower() == "y": brand = input("Enter item brand: ") voltage = input("Enter item voltage: ") new_item = electric_appliances_class.ElectricAppliances( code, description, price, rental_price, brand, voltage) else: new_item = inventory_class.Inventory(code, description, price, rental_price) FULL_INVENTORY[code] = new_item.return_as_dictionary() print("New inventory item added")
def test_furniture_class(self): """tests furniture class""" b = fu.Furniture("test product code", "test description", 52,"26","ToysRUs","900MV") self.assertEqual(b.returnasdictionary(), {'productcode':"test product code", 'description':"test description", 'marketprice':52, 'rentalprice':"26", 'material':"ToysRUs", 'size':"900MV"})
def setUp(self): """Define set up characteristics of furniture class tests.""" print('setUp') item_code = 6546 description = "Couch" market_price = 600 rental_price = 10 material = "Fabric" size = "S" self.test_furniture_item = furniture_class.Furniture( item_code, description, market_price, rental_price, material, size) self.test_furn_dict = self.test_furniture_item.return_as_dictionary()
def add_new_item(): """Add a new item to the inventory Note: I dislike this function. It operates on a global instead of an arg, and returns nothing, instead printing to stdout. I'd prefer it to accept a dict as an arg then return the new dict, or raise an error if something goes wrong. """ item_code = input("Enter item code: ") item_description = input("Enter item description: ") item_rental_price = input("Enter item rental price: ") item_price = get_price(item_code) is_furniture = input("Is this item a piece of furniture? (Y/N): ") if is_furniture.lower() == "y": item_material = input("Enter item material: ") item_size = input("Enter item size (S,M,L,XL): ") new_item = furniture_class.Furniture(item_code, item_description, item_price, item_rental_price, item_material, item_size) else: is_electric_appliance = \ input("Is this item an electric appliance? (Y/N): ") if is_electric_appliance.lower() == "y": item_brand = input("Enter item brand: ") item_voltage = input("Enter item voltage: ") new_item = electric_appliances_class.ElectricAppliances( item_code, item_description, item_price, item_rental_price, item_brand, item_voltage) else: new_item = inventory_class.Inventory(item_code, item_description, item_price, item_rental_price) FULL_INVENTORY[item_code] = new_item.return_as_dictionary() print("New inventory item added")
def add_new_item(): """Add new item to full_inventory""" # Consider passing as argument global full_inventory # pylint: disable=global-statement, invalid-name item_code = input("Enter item code: ") item_description = input("Enter item description: ") item_rental_price = input("Enter item rental price: ") # Get price from the market prices module item_price = market_prices.get_latest_price(item_code) is_furniture = input("Is this item a piece of furniture? (Y/N): ") if is_furniture.lower() == "y": item_material = input("Enter item material: ") item_size = input("Enter item size (S,M,L,XL): ") new_item = furniture.Furniture(item_code, item_description, item_price, item_rental_price, item_material, item_size) else: is_electric_appliance = input("Is this item an electric appliance?" " (Y/N): ") if is_electric_appliance.lower() == "y": item_brand = input("Enter item brand: ") item_voltage = input("Enter item voltage: ") new_item = elec.ElectricAppliances(item_code, item_description, item_price, item_rental_price, item_brand, item_voltage) else: new_item = inventory.Inventory(item_code, item_description, item_price, item_rental_price) full_inventory[item_code] = new_item.return_as_dictionary() print("New inventory item added")
def setUp(self): """This method is executed prior to each test""" self.furniture = fc.Furniture("001", "table", "$20", "$3", "wood", "XL") self.result = self.furniture.return_as_dictionary()