Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment, you are required to design, implement and test a program that can be used to manage a simple shopping cart system with

In this assignment, you are required to design, implement and test a program that can be used
to manage a simple shopping cart system with shopping records, which are stored in a list.
Your program must provide an interactive design that allows the user to:
create new shopping records and add them to the shopping cart system;
display all shopping records with details;
calculate the total cost of all the records or the records of searching outcome;
search for specific shopping records in all records;
The program is to be implemented by Python and as a .ipynb file running on a Jupyter notebook.
Shopping cart system
Figure 1 illustrates the catalogue provided for customers before they use your program. You
do not need to add the picture or table of catalogue into your program. The data in the catalogue
for your program have been added to the product_list and price_list of the Product and price
lists.txt. Please directly copy the text and paste it to your .ipynb file without modification.
Figure 1: Catalogue
Figures 2 and 3 on the next page illustrate the shopping cart system with sample outcomes of
show_record() and sorting. Please use this illustration as the reference for the following
descriptions.
Shopping records
This program will hold or encapsulate data for the product code, product name, price, quantity
and shipping method. With respect to each of the attributes, a shopping record can be
represented like the following sample:
"2/Tea Set/High/39.95/1/Pick-up"
This can be deciphered as: for this shopping record, the product code is 2, the product name
is Tea Set, its value is high (When the unit price of a product is no less than $30, its value
is high. Otherwise, it is low), unit price is $39.95, quantity is 1, shipping method is Pick-up.
You should create a global variable - list - to store all such shopping records. For the sake of
easy explanation, we refer to this variable by shopping_record_list in the rest of this document.
Some limitations must be imposed on the shopping records:
Product code must be "END"(case sensitive) or an integer number and only if:
0<= code <=39;
Quantity must be an integer number and only if:
0< quantity <=49;
Your Tasks
It is strongly suggested that the following approach is to be taken to design and implement the
program.
Interactive design
You should implement and test the Interactive design of the shopping cart system for users to
input value and obtain outputs. Input functions should be applied for users to enter shipping
method, product code and quantity.
The add_record() Function
You should design, implement and test a function to add a shopping record to the shopping cart
system. A shopping record will be added to the shopping cart system each time when all the
inputs (product code, quantity and shipping method) are valid. The program will continually
ask the user to input the record by three input functions until "END" (case sensitive) is input
for the product code. The function handles the following tasks:
The "product code" is obtained by the first input function. Validate if the input for
"product code" is correct by using the function is_valid_code() described below;
If the valid "product code" is not "END". Collect corresponding product name and price
from the product_list and price_list according to "product code" for the shopping record;
If the entered "product code" is "END". Stop the iteration and collect all the entered
records and then run the show_records() Function.
The "quantity" is obtained by the second input function. Validate if the input for
"quantity" is correct by using the function is_valid_quantity() described below;
The "shipping method" is obtained by the third input function. Validate inputs are
"Pick-up" and "Delivery", case insensitive.
Add the shopping record into the shopping_record_list list if all data are valid,
otherwise, return an error message for each input function;
The is_valid_code() Function
You should design, implement and test a function to validate the data input for the product code
attribute of a shopping record. The function should alert an error message and return false if
the input is invalid, otherwise, return true.
Refer to the product code section on page 2 for what the function needs to check for validation.
The is_valid_quantity() Function
You should design, implement and test a function to validate the data input for the quantity
attribute of a shopping record. The function should alert an error message and return false if
the input is invalid, otherwise; return true.
Refer to the quantity section on page 2 for what the function needs to check for validation.
The show_records() Function
You should design, implement and test a function to show all existing records in the shopping
cart system. The function should access the shopping_record_list and print all existing
shopping records in an acceptable format as

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Systems A 360-degree Approach

Authors: Jawwad ShamsiMuhammad Khojaye

1st Edition

0429531575, 9780429531576

More Books

Students also viewed these Databases questions

Question

Describe the major barriers to the use of positive reinforcement.

Answered: 1 week ago