Python Forum
Shopping cart program
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Shopping cart program
#6
(Jun-26-2022, 11:29 PM)rob101 Wrote: If you want to take this forward, then it may be best if you posted the assignment notes, so that we don't start down the wrong road.

IMHO you don't need more than 3 user options, which will make for a more user friendly experience. As an example, why make the user have to 'choose' to view the shopping cart (unless that's a part of the assignment notes)? Surely this should be on display by default.

The total cost of the shopping can also be a part of the shopping cart view function, so no need for any 'Compute total'.

This is the approach I would take:

cart = []         #holds the cart items
item_price = []   #holds the price of each item

while True:
    if cart:
        #call the view cart function so that the shopping cart is always on display
        pass  #remove this line when the function has been defined
    else:
        print("\nYour shopping cart is empty.\n")    
    print("Shopping Cart Options\n")
    print ("1. Add items")
    print ("2. Remove Items")
    print ("3. Quit")
 
    option = input("> ")

    if option == '1':
        #call the add items function
        pass #remove this line when the function has been defined

    if option == '2':
        if cart:
            #call the remove items function
            pass #remove this line when the function has been defined
        else:
            print("\nThere are no items in your shopping cart.\n")

    if option == '3':
        if cart:
            #warn the user that there are items in the shopping cart and get positive feedback before quitting
            pass #remove this line when the above in functional 
        else:
            print("\nYour shopping cart is empty.\n")
            check = "yes"
        if check == "yes":
            print("\nApplication exit")
            break
we had to have 5 options and then where we could view the cart and remove an item. it also has to have where you can have more than one item to compute the notes he posted only had for list's which I got stuck many of the other students as well
Reply


Messages In This Thread
Shopping cart program - by Tofuboi03 - Jun-26-2022, 06:12 AM
RE: Shopping cart program - by rob101 - Jun-26-2022, 07:36 AM
RE: Shopping cart program - by rob101 - Jun-26-2022, 11:29 PM
RE: Shopping cart program - by Tofuboi03 - Jun-27-2022, 03:50 AM
RE: Shopping cart program - by BashBedlam - Jun-26-2022, 11:58 PM
RE: Shopping cart program - by Tofuboi03 - Jun-27-2022, 03:43 AM
RE: Shopping cart program - by rob101 - Jun-27-2022, 07:53 AM
RE: Shopping cart program - by shoesinquiry - Sep-07-2023, 09:41 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  project shopping cart pkmnmewtwo 1 3,393 May-03-2020, 10:46 PM
Last Post: pkmnmewtwo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020