You are tasked with creating a text-based program for simulating a supermarket self-service checkout using the Python 3 programming language. The assignment is broken up into four main components: 1.)...

1 answer below »
You are tasked with creating a text-based program for simulating a supermarket self-service checkout using the Python 3 programming language. The assignment is broken up into four main components: 1.) Design and model two classes: Product and CheckoutRegister, 2.) Create an activity chart which describes the behaviour of the checkout system, 3.) Create a computer program that allows a user to interactively check out a number of products, then provides an opportunity to enter some virtual money to pay for the products and finally and prints out a receipt for the user (to the screen, not on paper), and finally 4.) Explain and integrate some code into your checkout program that places the products purchased into virtual shopping bags. Your submission should consist of one Microsoft Word or LibreOffice document containing the first two parts of the assignment, and three Python scripts that implement the computer program (checkoutregister.py, product.py and main.py). The main.py script runs the main logic of the program and will use instances of the CheckoutRegister and Product classes to simulate checking out of the supermarket. You are provided with a Microsoft Word template to help you complete the first two parts of this assignment. Towards the end of this document you will also be provided with the output of a simulated run of the completed computer program which may help you with this assignment.


School of Science, Engineering and Information Technology ITECH1400 – Foundations of Programming School of Science, Engineering and Information Technology ITECH1400 - Assignment 1 – Supermarket Self-Service Checkout Student Name:Student ID: Assignment Part 1 Details – Class Design Insert your list/table of possible product properties here… Product Properties (All) Insert your list/table of key product properties here… Product Properties (Key) Complete the class diagram of your final Product class here… Product Class Diagram CheckoutRegister Class Diagram Complete the class diagram of your final CheckoutRegister class here… Assignment Part 2 – Activity Flowchart Insert your activity flowchart of the supermarket checkout process here… If your flowchart is large then place it on the following page. Assignment Part 3 – Software Implementation Do not place your code here – provide the code as separate .py files submitted with this document. 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: ___________________________ def get_float(prompt): # ____________________________________ value = float(0.0) # ____________________________________ while True: try: # ____________________________________ value = float(input(prompt)) # ____________________________________ if value < 0.0:="" print("we="" don't="" accept="" negative="" money!")="" continue="" #="" ____________________________________="" break="" #="" ____________________________________="" except="" valueerror:="" print('please="" enter="" a="" valid="" floating="" point="" value.')="" #="" ____________________________________="" return="" value="" #="" function="" to:="" ___________________________="" def="" bag_products(product_list):="" #="" ____________________________________="" bag_list="[]" non_bagged_items="[]" max_bag_weight="5.0" #="" ____________________________________="" for="" product="" in="" product_list:="" #="" ____________________________________="" if="" product.weight=""> MAX_BAG_WEIGHT: product_list.remove(product) non_bagged_items.append(product) # ____________________________________ current_bag_contents = [] current_bag_weight = 0.0 # ____________________________________ while len(product_list) > 0: # ____________________________________ temp_product = product_list[0] product_list.remove(temp_product) # ____________________________________ if current_bag_weight + temp_product.weight < max_bag_weight:="" #="" ____________________________________="" current_bag_contents.append(temp_product)="" current_bag_weight="" +="temp_product.weight" #="" ____________________________________="" if="" (len(product_list)="=" 0):="" bag_list.append(current_bag_contents)="" #="" ____________________________________="" else:="" bag_list.append(current_bag_contents)="" #="" ____________________________________="" current_bag_contents="[]" current_bag_weight="0.0" #="" ____________________________________="" for="" index,="" bag="" in="" enumerate(bag_list):="" output='Bag ' +="" str(index="" +="" 1)="" +="" '="" contains:="" '="" #="" ____________________________________="" for="" product="" in="" bag:="" output="" +="product.name" +="" '\t'="" print(output,="" '\n')="" #="" ____________________________________="" if="" (len(non_bagged_items)=""> 0): output = 'Non-bagged items: ' # ____________________________________ 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) Comments: CRICOS Provider No. 00103D Insert file name here Page 6 of 8 CRICOS Provider No. 00103D Page 8 of 8 ITECH1400 – Foundations of Programming School of Science, Engineering and Information Technology CRICOS Provider No. 00103D Page 1 of 7 ITECH1400 - Assignment 1 – Supermarket Self-Service Checkout Due Date: 5pm, Friday of Week 7 This assignment will test your skills in designing and programming applications to specification and is worth 20% of your non-invigilated (type A) marks for this course. This is an INDIVIDUAL ASSIGNMENT – and while you may discuss it with your fellow students, you must not share designs or code or you will be in breach of the university plagiarism rules. This assignment should take you approximately 20 hours to complete. Assignment Overview You are tasked with creating a text-based program for simulating a supermarket self-service checkout using the Python 3 programming language. The assignment is broken up into four main components: 1.) Design and model two classes: Product and CheckoutRegister, 2.) Create an activity chart which describes the behaviour of the checkout system, 3.) Create a computer program that allows a user to interactively check out a number of products, then provides an opportunity to enter some virtual money to pay for the products and finally and prints out a receipt for the user (to the screen, not on paper), and finally 4.) Explain and integrate some code into your checkout program that places the products purchased into virtual shopping bags. Your submission should consist of one Microsoft Word or LibreOffice document containing the first two parts of the assignment, and three Python scripts that implement the computer program (checkoutregister.py, product.py and main.py). The main.py script runs the main logic of the program and will use instances of the CheckoutRegister and Product classes to simulate checking out of the supermarket. You are provided with a Microsoft Word template to help you complete the first two parts of this assignment. Towards the end of this document you will also be provided with the output of a simulated run of the completed computer program which may help you with this assignment. ITECH1400 – Foundations of Programming School of Science, Engineering and Information Technology CRICOS Provider No. 00103D Page 2 of 7 Assignment Part 1 Details – Class Design Think of a product that you can buy from a supermarket, like maybe a can of soup or an apple. Start by listing all the properties of that object that you can think of – try to come up with at least ten general properties of a Product and write these down in your Assignment_Part_1_ Microsoft Word document. Next, use the process of abstraction to cut the number of properties back to only four ‘key’ properties – write these down in the next section of your Word document. Take a look at the week 2 lecture slides if you need a reminder on how to go about this. Now, fill in the class diagram for your Product class in the Word document template provided. Your product class does not have to have any methods (i.e. functions) associated with it to perform any actions other than a constructor which takes and set the four key properties that you’ve identified. Next we’ll move on to CheckoutRegister class – think about what information the checkout
Answered Same DayMay 08, 2020ITECH1400

Answer To: You are tasked with creating a text-based program for simulating a supermarket self-service checkout...

Abr Writing answered on May 09 2020
147 Votes
Supermarket Self-Service Checkout.html


In [1]:

%run main.py
----- Welcome to FedUni checkout! -----
Please enter the barcode of the product: 123
Milk 2.0
Would you like to scan another product? (Y/N)y
Please enter the barcode of the product: 456
Coffee 3.0
Would you like to scan another product? (Y/N)y
Please enter the barcode of the product: 999
This
product does not exist in our inventory.
Would you like to scan another product? (Y/N)n
Payment due: 5.0
Please enter an amount to pay: 1
5.0
1.0
Payment due: 4.0
Please enter an amount to pay: -3
We don't accept negative money!
Please enter an amount to pay: 5
4.0
5.0
----- Final Receipt -----
Milk 2.0
Coffee 3.0
Total amount due: 5.0
Amount received: 6.0
Change given: 1.0
Thank you for shopping at FedUni!
(N)ext customer, or (Q)uit?q
main.py
from CheckoutRegister import CheckoutRegister
# If the final option of (N)ext customer is chosen, the program runs again
moreCustomer = True
while moreCustomer:
    print('----- Welcome to FedUni checkout! -----')
    register = CheckoutRegister()
    #
    while True:
        # Taking user input: barcode of the product
        barcode = float(input('Please enter the barcode of the product: '))
        # Scanning the product using the function scan_item
        register.scan_item(barcode)
        # Taking user input: More products or not?
        prod = input('Would you like to scan another product? (Y/N)')
        # Taking decision based on customer's input
        if prod.lower() == "n":
            # Calculating the amount due by the customer
            register.due()
            due = 0
            for idx in register.itemList:
                due += register.product.price[idx]
            print('Payment due: ', register.total)
            total = register.total
            #
            while True:
                tmp = register.accept_payment(float(input('Please enter an amount to pay: ')))
                if tmp == "negative"    :
                    continue
                print(total)
                print(register.pay[-1])
                if total > register.pay[-1]:
                    print('Payment due: ', total - register.pay[-1])
                    total = total - register.pay[-1]
                else:
                    break
            
            # Printing the receipt
            register.print_receipt()            
            break
        else:
            continue
            
    # Taking user input: More customers?
    next = input('(N)ext customer, or (Q)uit?')    
    if next.lower == 'n':
        continue
    else:
        moreCustomer = False
Product.py
import pandas as pd
class Product:
    def __init__(self):
        fileName = 'products.csv'
        # reading product data from fileName (.CSV file)
        df = pd.read_csv(fileName)
        self.barcode = list(df.barcode)
        self.name = list(df.name)
        self.price = list(df.price)
products.csv
barcode,name,price
123,Milk,2
212,Bread,3
456,Coffee,3
923,Sugar,5.5
Supermarket Self-Service Checkout.ipynb
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"----- Welcome to FedUni checkout! -----\n",
"Please enter the barcode of the product: 123\n",
"Milk 2.0\n",
"Would you like to scan another product? (Y/N)y\n",
"Please enter the barcode of the product: 456\n",
"Coffee 3.0\n",
"Would you like to scan another product? (Y/N)y\n",
"Please enter the barcode of the product: 999\n",
"This product does not exist in our inventory.\n",
"Would you like to scan another product? (Y/N)n\n",
"Payment due: 5.0\n",
"Please enter an amount to pay: 1\n",
"5.0\n",
"1.0\n",
"Payment due: 4.0\n",
"Please enter an amount to pay: -3\n",
"We don't accept negative money!\n",
"Please enter an amount to pay: 5\n",
"4.0\n",
"5.0\n",
"----- Final Receipt ----- \n",
"Milk 2.0\n",
"Coffee...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here