You are on page 1of 2

Online Shopping Cart:

Let's say someone asks you to add an online store to their website. The user's chosen things for
purchase should be able to be kept in the shopping cart, and it should also be able to keep track of
how much everything costs in total. The following features must be added to the shopping cart:

Function Argument Return Type Function Description


‘addItem’ ‘string item_name, ‘bool’ The item name and
float price’ price are inputted as
arguments into this
function, which adds
the item to the cart. If
the item is
successfully added, it
returns true; if it is
already in the cart, it
returns false.
‘removeItem’ ‘string item_name’ ‘bool’ By accepting the item
name as an input, this
function removes an
item from the
shopping cart. If the
item is properly
removed, it returns
true; otherwise, it
returns false.
‘updateItem’ ‘string item_name, ‘bool’ By accepting the item
float price’ name and the new
price as parameters,
this function adjusts
the price of an item in
the cart. If the item is
in the cart and the
price update is
successful, it returns
true; otherwise, it
returns false.
‘getItems’ ‘void’ ‘list’ The list of all the items
currently in the cart is
what this method
returns.
‘getTotal’ ‘void’ ‘float’ The cost of all the
items in the cart is
returned by this
function.

Here are some test cases for this system:


Test Case Test Case Input Expected Output Explanation
Description
‘Zero’ Add item to the cart ‘“Item 01”,20’ ‘True’ adds "Item 01" with
a cost of 20 to the
shopping basket.

‘One’ Add item already in ‘” Item 01”,40’ ‘False’ "Item 01" already
cart has a price of 20 in
the cart.

‘Two’ Remove item from ‘” Item 01”’ ‘True’ Removing "Item 01"
cart from the shopping
cart
‘Three’ Remove item not in ‘” Item 02”’ ‘False’ The cart lacks "Item
cart 02."
‘Four’ Update item price ‘” Item 01”,30’ ‘True’ Changes "Item’s"
cost to 30
‘Five’ Update price of item ‘” Item 02”,56’ ‘False’ The cart lacks "Item
not in cart 02."
‘Six’ Get item in cart ‘void’ ‘[“Item 01”]’ returns a list of the
items in the cart,
starting with "Item
01".
‘Seven’ Add another item to ‘” Item 02”,50” ‘True’ adds "Item 02" with
cart a cost of 50 to the
shopping basket.
‘Eight’ Get total cost of ‘void’ ‘80’ gives back the total
items in cart price of the cart's
items, which is.
30 + 50 = 80.

You might also like