Write an example of a shopping mall tutorial

Source: Internet
Author: User
Job: Shopping mall

Product Display, Price

Buy, add to Cart

Payment, not enough money

The flowchart is as follows:

There are 4 files in the code, as follows:

User files:

Alex 666geng 888zhang 222lou 250zeng 333

Product Documents:

10001 mi 3 2699 5010002 byd song 100001 9110003 gree inverter air conditioning 20000 410004 TCL TV 6000 9810005 Lenovo 001 5600 99210006 running chicken 250 66310007 Volkswagen 58000 9710008 Mazda 68000 43

Shopping Cart File:

10002 BYD Song 100001 1 geng10006 running chicken 1 geng10008 Mazda 68000 1 geng10003 gree inverter air conditioning 20000 1 Geng

Wallet File:

Geng 115880zeng 126748

The code is as follows:

= =, end=,) line =+,shopping_name+,shopping_price+,shopping_stock+=,) User_line = = user = input (pwd = =%== stock = input (num) <= (shoppings[stock_list.index (stock)][],shoppings[stock_list.index (stock) [] = str (shoppings[stock_   List.index (stock) [])-(num) > (Shoppings[stock_list.index (stock)] [,) shop_list = + =,) line = Username = = (Price) *= Cost +== input (=,) line = Username = = = = = = = = STR (BAL) +,) User_wallet. Join (user_wallet) + = = =, line = Username = = (pur SE) >= = str ((purse)-__name__ = = = = ***************************************************************************** [; 1m Welcome to Pig Pig Shopping website, wish you a happy shopping! \*******************************************************************************************== input (= = lists[= lists[= input (Shopping_index = =,) Shopping_list =. Join (shopping_list) + = =,) user_line. Join (User_line) +) The result of the operation is as follows: Welcome to Pig Pig buy website, I wish you a happy shopping! Item Number: Product Name: Commodity Price: Commodity Library       Save: *************************************************************************************10001 Xiaomi 3 2699 50        10002 BYD Song 100001 92 10003 gree Inverter air conditioning 20000 5 10004 TCL TV 6000 98 10005 Lenovo 001 5600 992 10006 running chicken 250 664 10007 Volkswagen 5 8000 97 10008 Mazda 68000 44 Please enter your user name: Geng Please enter your password: 888 Hello, Welcome to Geng, Happy shopping! Please enter the number of items you want to buy (enter quit shopping): 10002 Please enter the number of items you want to buy: 1 Please enter the number of items you want to buy (enter quit shopping): 10006 Please enter the number of items you want to buy: 1 Please enter the number of the item you want to buy ( Enter quit shopping): 10008 Please enter the number of items you want to buy: 1 Please enter the number of items you want to buy (enter quit shopping): 10003 Please enter the number of items you want to buy: 1 Please enter the number of the item you want to buy (enter quit to exit the shopping): Quit Sorry, Your balance is insufficient, please recharge please enter the amount you want to recharge: 100000 payment success!

The above code runs the following process:

(1) Display commodity information;

(2) User login verification;

(3) User input want to buy products and quantity, enter quit shopping;

(4) Add to Cart file;

(5) Checkout, go shopping cart calculate shopping cost;

(6) Call the user wallet file to see if the balance is sufficient to pay;

(7) The balance is equal to the order shopping, the payment is successful, the balance is insufficient, the user recharge;

(8) Call the recharge module to recharge;

(9) Recursion, judge know that the user after the balance of recharge is greater than the cost of the purchase, payment success;

(10) End the procedure.

Master knowledge:

(1) List traversal method, list modification is to first read to a list, and then according to the user input information to modify;

(2) Open and close the file back and forth;

(3) applied to recursion, that is, when the user's balance has been less, recursion, until the user's balance is greater than the cost of shopping;

(4) Start and end of Loop (break), start and end of program (Sys.exit), start and end of function (return);

(5) The list is associated with the index condition, which solves the problem by reading the order of the files.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.