Assignment Part 1 Details – Class Design
Assignment Part 1 Details – Class Design
Insert your list/table of possible product properties here…
Product Properties (All)
prodName |
prodCode |
sellPrice |
prodCategory |
stockQty |
manufacturerID |
manufacturerCompany |
purchaseCost |
dateAdded |
dateModify |
Insert your list/table of key product properties here…
Product Properties (Key)
prodCode |
prodName |
sellPrice |
prodCategory |
Complete the class diagram of your final Product class here…
Product Class DiagramCheckoutRegister Class Diagram
Complete the class diagram of your final CheckoutRegister class here…Assignment Part 2 – Activity FlowchartAssignment Part 3 – Software Implementation
The .py files are attached (3 .py files)
Assignment Part 4 – Code Explanation and Use
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: Input a number and convert to float type
def get_float(prompt):
# initialize value to 0.0
value = float(0.0)
# loop and check if value > 0.0 or check validity of floating value using exception
while True:
try:
# input from keyboard and convert to float type and store it in value
value = float(input(prompt))
# check if value is negative
if value < 0.0:
print(“We don’t accept negative money!”)
continue
# if value is negative, print the error message and exit the loop
break
# catch the exception
except ValueError:
print(‘Please enter a valid floating point value.’)
# return value when valid floating number is inputted and value is > 0.0
return value
# Function to: Add the product to shopping cart bag
def bag_products(product_list):
# create list of shopping bag and products which are not stored in shopping bag
bag_list = []
non_bagged_items = []
MAX_BAG_WEIGHT = 5.0
# loop through the product list
for product in product_list:
# if weight is > MAX_BAG_WEIGHT.
# then remove product from the product list and add product
# to non-bagged list
if product.weight > MAX_BAG_WEIGHT:
product_list.remove(product)
non_bagged_items.append(product)
# create list of current shopping bag and set the current bag weight = 0.0
current_bag_contents = []
current_bag_weight = 0.0
# loop till the length of the product_list > 0
while len(product_list) > 0:
# store product at index 0 to temp_product variable and
# remove the product stored in temp_product variable from the product list
temp_product = product_list[0]
product_list.remove(temp_product)
# check if current bag weight + weight of the temp_product < MAX_BAG_WEIGHT
if current_bag_weight + temp_product.weight < MAX_BAG_WEIGHT:
# add temp_product to current bag and add the weight of temp_product weight
# to the current bag weight
current_bag_contents.append(temp_product)
current_bag_weight += temp_product.weight
# check if length of the product list = 0 and store the current bag list
# to the bag list
if (len(product_list) == 0):
bag_list.append(current_bag_contents)
# check if current bag weight + temp_product weight > MAX_BAG_WEIGHT
# then store current bag list to the bag list
else:
bag_list.append(current_bag_contents)
# reset the current bag list to null and current bag weight = 0.0
current_bag_contents = []
current_bag_weight = 0.0
# loop through the bag list to print the products stored in the shopping bag
for index, bag in enumerate(bag_list):
output = ‘Bag ‘ + str(index + 1) + ‘ contains: ‘
# print product name stored in the bag
for product in bag:
output += product.name + ‘t’
print(output, ‘n’)
# check if length of the non bagged items > 0 then print the non bagged products
if (len(non_bagged_items) > 0):
output = ‘Non-bagged items: ‘
# loop through to print non bagged products name
for item in non_bagged_items:
output += item + ‘t’
print(output,’n’)
Assignment 1 – FedUni Checkout
Student name: Student ID:
Part |
Assessment Criteria |
Weight |
Mark |
1a |
Identification of properties of a typical supermarket Product. |
10 * 0.5 = 5 marks |
|
1b |
Application of abstraction to identify key properties of a typical supermarket Product as well as creation of a suitable Class Diagram. |
4 marks |
|
1c |
Identification of the key properties of a CheckoutRegister as well as creation of a suitable Class Diagram which uses those properties, plus the four method signatures provided. |
4 marks |
|
2 |
Creation of an activity flowchart which clearly indicates how the program should operate, using the correct symbols for elements such as start/end points, processes and decisions/branches |
10 marks |
|
3 |
Programming of the product checkout simulation so that it: i) Creates a small number of Product instances that may be purchased, ii) Accepts simulated ‘scanning’ of a Product to identify it (including refusal to identify products which do not exist), iii) Adds a scanned Product to the CheckoutRegister’s list of products being purchased, iv) Allows the checkout of multiple products, v) Accepts ‘virtual money’ to pay for those products (you must pay enough to cover the cost of the items checked out), and vi) Prints a final receipt of the products purchased, along with the total cost, total paid and any change given. |
5 + 5 + 5 + 5 + 5 + 5 = 30 marks. |
i) ii) iiI) iv) v) vi) Total: |
4a |
Analysis and documentation via code comments of the two functions provided. |
(8 * 0.5) + (16 * 0.5) = 12 marks |
|
4b |
Incorporation of the two functions provided into your main submission so that the program does not crash when an illegal money value is provided, and also virtually ‘bags up’ the products purchased. |
2 |
|
Assignment total (out of 65 marks) |
|||
Contribution to grade (out of 20 marks) |