Insert your list/table of possible product properties here…
Product Properties (All)
price |
mfgDate |
expiryDate |
BatchNo |
weight |
barcode |
name |
ingredients |
address |
|
mfgUnit |
fax |
Insert your list/table of key product properties here…
Product Properties (Key)
name |
price |
weight |
barcode |
Complete the class diagram of your final Product class here
Update the below code to insert comments describing what the code is doing – for each line starting with a hash symbol (#) you should write your code comments after the hash. You may add a second line of comments if you require more space.
# Function to: read a float value from the user
#and return this float value to the calling function
def get_float(prompt):
# take a variable value of type float and initialize it
# with value 0.0
value = float(0.0)
# infinite loop to carry on till a valid float value is entered by the user
while True:
try:
# take an input from the user
# typecast that entered value into a float value
value = float(input(prompt))
# if value was successfully parsed
# but the entered value is less then 0,
# print an error message and continue to loop
if value < 0.0:
print(“We don’t accept negative money!”)
continue
# value entered by the user is a valid value.
# break the loop
break
# value entered by the user was not a valid float value
# so an exception is thrown
except ValueError:
print(‘Please enter a valid floating point value.’)
# return the parsed float value to the calling function.
return value
# Function to: bag the products that are purchased by the user
def bag_products(product_list):
# list of the bags as the items purchased by the user
# may take more then one bags
bag_list = []
non_bagged_items = []
MAX_BAG_WEIGHT = 5.0
# for each product in the list of goods purchased by the user
# perform this loop
for product in product_list
# weight of current product is more then
# the maximum weight that this bag can hold,
# so add this product to the list of items which will not be bagged
if product.weight > MAX_BAG_WEIGHT:
product_list.remove(product)
non_bagged_items.append(product)
# take an empty new bag to place the goods of the user
current_bag_contents = []
current_bag_weight = 0.0
# loop until the basket of goods purchased by the user still has items
while len(product_list) > 0:
# take the first products out of the basket
# and name it as temp_product
temp_product = product_list[0]
product_list.remove(temp_product)
# check whether the current product can be added
# to the current bag or not
# for this, check that adding this product will not overfloew the bag
if current_bag_weight + temp_product.weight < MAX_BAG_WEIGHT:
# if this product can be added, add it to the current bag
current_bag_contents.append(temp_product)
current_bag_weight += temp_product.weight
# if all the items of the basket are packed
# add this bag to list of bags for the user
if (len(product_list) == 0):
bag_list.append(current_bag_contents)
# the current product can not be added to this bag,
# so add the current bag to the list of bags for the user
else:
bag_list.append(current_bag_contents)
# take a fresh bag and set its weight to 0
current_bag_contents = []
current_bag_weight = 0.0
# loop through list of all bags to print their contents
# by bag number
for index, bag in enumerate(bag_list):
output = ‘Bag ‘ + str(index + 1) + ‘ contains: ‘
# for each product in the current bag, add its name
# to the list of user items in this bag
for product in bag:
output += product.name + ‘t’
print(output, ‘n’)
# there are also some items that were not packed
if (len(non_bagged_items) > 0):
output = ‘Non-bagged items: ‘
# traverse these items to print their contents
for item in non_bagged_items:
output += item + ‘t’
print(output,’n’)
Essay Writing Service Features
Our Experience
No matter how complex your assignment is, we can find the right professional for your specific task. Contact Essay is an essay writing company that hires only the smartest minds to help you with your projects. Our expertise allows us to provide students with high-quality academic writing, editing & proofreading services.Free Features
Free revision policy
$10Free bibliography & reference
$8Free title page
$8Free formatting
$8How Our Essay Writing Service Works
First, you will need to complete an order form. It's not difficult but, in case there is anything you find not to be clear, you may always call us so that we can guide you through it. On the order form, you will need to include some basic information concerning your order: subject, topic, number of pages, etc. We also encourage our clients to upload any relevant information or sources that will help.
Complete the order formOnce we have all the information and instructions that we need, we select the most suitable writer for your assignment. While everything seems to be clear, the writer, who has complete knowledge of the subject, may need clarification from you. It is at that point that you would receive a call or email from us.
Writer’s assignmentAs soon as the writer has finished, it will be delivered both to the website and to your email address so that you will not miss it. If your deadline is close at hand, we will place a call to you to make sure that you receive the paper on time.
Completing the order and download