Answered step by step
Verified Expert Solution
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 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 productlist and pricelist of the Product and price
lists.txt Please directly copy the text and paste it to your ipynb file without modification.
Figure : Catalogue
Figures and on the next page illustrate the shopping cart system with sample outcomes of
showrecord 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:
Tea SetHighPickup
This can be deciphered as: for this shopping record, the product code is the product name
is Tea Set, its value is high When the unit price of a product is no less than $ its value
is high. Otherwise, it is low unit price is $ quantity is shipping method is Pickup
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 shoppingrecordlist 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:
code ;
Quantity must be an integer number and only if:
quantity ;
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 addrecord 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 isvalidcode described below;
If the valid "product code" is not "END". Collect corresponding product name and price
from the productlist and pricelist 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 showrecords Function.
The "quantity" is obtained by the second input function. Validate if the input for
"quantity" is correct by using the function isvalidquantity described below;
The "shipping method" is obtained by the third input function. Validate inputs are
"Pickup and "Delivery", case insensitive.
Add the shopping record into the shoppingrecordlist list if all data are valid,
otherwise, return an error message for each input function;
The isvalidcode 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 for what the function needs to check for validation.
The isvalidquantity 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 for what the function needs to check for validation.
The showrecords Function
You should design, implement and test a function to show all existing records in the shopping
cart system. The function should access the shoppingrecordlist and print all existing
shopping records in an acceptable format as
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started