Advertisement
okelikai

Final Project

Jun 1st, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 12.45 KB | None | 0 0
  1. import random
  2. import os
  3. import time
  4.  
  5. global money_in_wallet
  6. global dashes
  7. global shopping_cart
  8. global shopping_cart_money
  9. global ys
  10. global ns
  11.  
  12.  
  13. shopping_cart = []
  14. shopping_cart_money = 0
  15. money_in_wallet = random.choice([200,250,300,350])
  16. ys = ['Y', 'y']
  17. ns = ['N', 'n']
  18.  
  19. def keyboard_store():
  20.     dashes = '-' * 30
  21.     def store_menu():
  22.         print """
  23. %s
  24.        
  25. Welcome to the Keyboard Shop!
  26.        
  27. %s\n
  28.        """ % (dashes, dashes)
  29.         store_options()
  30.    
  31.     def store_options():
  32.         store_option_choice = raw_input("""
  33. What would you like to do?
  34.        
  35.    1. Build a New Keyboard
  36.    2. Buy Prebuilt Keyboards
  37.    3. Checkout\n\n    > """)
  38.         if store_option_choice == '1':
  39.             os.system('clear')
  40.             build_keyboard()
  41.         elif store_option_choice == '2':
  42.             os.system('clear')
  43.             purchase_prebuilt()
  44.         elif store_option_choice == '3':
  45.             checkout()
  46.         else:
  47.             print "That's not an option!"
  48.             time.sleep(1)
  49.             os.system('clear')
  50.             keyboard_store()
  51.  
  52.     def build_keyboard(): # Option 1
  53.         custom_keyboard_cost = 0
  54.        
  55.         def keyboard_size_fun(building_run):
  56.             global keyboard_size
  57.             keyboard_size = raw_input("To start, what form factor would you like for your keyboard? This determines how large your keyboard will be.\n   1. 40%\n   2. 60%\n   3. 80%\n   4. 100%\n> ")
  58.             if keyboard_size == '1':
  59.                 keyboard_size = '40%'
  60.                 custom_keyboard_cost + 49.99
  61.                  while building_run > 0: # While loop determining if it is first build or in editing stage
  62.                     keyboard_switch_fun(building_run)
  63.                 else:
  64.                     build_keyboard_finalize(building_run)
  65.             elif keyboard_size == '2':
  66.                 keyboard_size = '60%'
  67.                 custom_keyboard_cost + 59.99
  68.                 while building_run > 0:
  69.                     keyboard_switch_fun(building_run)
  70.                 else:
  71.                     build_keyboard_finalize(building_run)
  72.             elif keyboard_size == '3':
  73.                 keyboard_size = '80%'
  74.                 custom_keyboard_cost + 69.99
  75.                 while building_run > 0:
  76.                     keyboard_switch_fun(building_run)
  77.                 else:
  78.                     build_keyboard_finalize(building_run)
  79.             elif keyboard_size == '4':
  80.                 keyboard_size = '100%'
  81.                 custom_keyboard_cost + 79.99
  82.                 while building_run > 0:
  83.                     keyboard_switch_fun(building_run)
  84.                 else:
  85.                     build_keyboard_finalize(building_run)
  86.             else:
  87.                 print "That's not an option"
  88.                 os.system('clear')
  89.                 keyboard_size_fun(building_run)
  90.                
  91.         def keyboard_switch_fun(building_run):
  92.             global keyboard_switch
  93.            
  94.             print custom_keyboard_cost
  95.            
  96.             keyboard_switch = raw_input("Now, what swtich type would you like? This changes how the typing feels and sounds and is the most important part of personalizing a keyboard.\n   1. Cherry MX Blue\n   2. Cherry MX Red\n   3. Cherry MX Brown\n   4. Cherry MX Green\n> ")
  97.             if keyboard_switch == '1':
  98.                 keyboard_switch = 'Cherry MX Blue'
  99.                 custom_keyboard_cost + 10
  100.                 while building_run > 0: # While loop determining if it is first build or in editing stage
  101.                     keyboard_color_one_fun(building_run)
  102.                 else:
  103.                     build_keyboard_finalize(building_run)
  104.             elif keyboard_switch == '2':
  105.                 keyboard_switch = 'Cherry MX Red'
  106.                 custom_keyboard_cost + 8
  107.                 while building_run > 0:
  108.                     keyboard_color_one_fun(building_run)
  109.                 else:
  110.                     build_keyboard_finalize(building_run)
  111.             elif keyboard_switch == '3':
  112.                 keyboard_switch = 'Cherry MX Brown'
  113.                 custom_keyboard_cost + 9
  114.                 while building_run > 0:
  115.                     keyboard_color_one_fun(building_run)
  116.                 else:
  117.                     build_keyboard_finalize(building_run)
  118.             elif keyboard_switch == '4':
  119.                 keyboard_switch = 'Cherry MX Green'
  120.                 custom_keyboard_cost + 12
  121.                 while building_run > 0:
  122.                     keyboard_color_one_fun(building_run)
  123.                 else:
  124.                     build_keyboard_finalize(building_run)
  125.             else:
  126.                 print "That's not an option"
  127.                 os.system('clear')
  128.                 keyboard_switch_fun(building_run)
  129.  
  130.         def keyboard_color_one_fun(building_run):
  131.             global keyboard_color_one
  132.             keyboard_color_one = raw_input("Now we choose the primary color of your keyboard, this will be the color of the base. What color do you want?\n> ")
  133.             while building_run > 0:
  134.                 keyboard_color_two_fun(building_run)
  135.             else:
  136.                 build_keyboard_finalize(building_run)
  137.  
  138.         def keyboard_color_two_fun(building_run):
  139.             global keyboard_color_two
  140.             keyboard_color_two = raw_input("Next is the secondary color, this will be the front plate right next to the keycaps.\n> ")
  141.             while building_run > 0:
  142.                 keycap_color_fun(building_run)
  143.             else:
  144.                 build_keyboard_finalize(building_run)
  145.  
  146.         def keycap_color_fun(building_run):
  147.             global keycap_color
  148.             keycap_color = raw_input("Finally for colors is the keycaps, these are what you will be looking at the most so choose wisely\n> ")
  149.             while building_run > 0:
  150.                 keyboard_RGB_fun(building_run)
  151.             else:
  152.                 build_keyboard_finalize(building_run)
  153.  
  154.         def keyboard_RGB_fun(building_run):
  155.             global keyboard_RGB
  156.             keyboard_RGB = raw_input("For the final choice, would you like RGB backlighting for your keyboard? With it you can costumize the color that your keys eminate through our free user friendly software. (Y/N)\n> ")
  157.             if keyboard_RGB in ys:
  158.                 keyboard_RGB = "Yes"
  159.                 custom_keyboard_cost + 20
  160.                 build_keyboard_finalize(building_run)
  161.             elif keyboard_RGB in ns:
  162.                 keyboard_RGB = "No"
  163.                 build_keyboard_finalize(building_run)
  164.         def build_keyboard_finalize(building_run):
  165.             building_run + 1
  166.             print """
  167. Here is what you chose:
  168.  
  169. 1. Keyboard Size:          %s
  170. 2. Keyboard Switch:        %s
  171. 3. Keyboard Base Color:    %s
  172. 4. Keyboard Plate Color:   %s
  173. 5. Keycap Color:           %s
  174. 6. Keyboard RGB:           %s
  175.  
  176. And the total for your keyboard is $%s
  177.    
  178. """ % (keyboard_size, keyboard_switch, keyboard_color_one, keyboard_color_two, keycap_color, keyboard_RGB, custom_keyboard_cost)
  179.  
  180.             def redo_custom_keyboard(building_run):
  181.                 building_run - 1
  182.                 redo_keyboard_section = raw_input("""
  183. which section do you want to start at?
  184.  
  185. 1. Keyboard Size:          
  186. 2. Keyboard Switch:        
  187. 3. Keyboard Base Color:    
  188. 4. Keyboard Plate Color:  
  189. 5. Keycap Color:          
  190. 6. Keyboard RGB:          
  191.  
  192. 7. Cancel""")
  193.                
  194.                 if redo_keyboard_section ==  '1':
  195.                     os.system('clear')
  196.                     keyboard_size_fun(building_run)
  197.                 elif redo_keyboard_section == '2':
  198.                     os.system('clear')
  199.                     keyboard_switch_fun(building_run)
  200.                 elif redo_keyboard_section == '3':
  201.                     os.system('clear')
  202.                     keyboard_color_one_fun(building_run)
  203.                 elif redo_keyboard_section == '4':
  204.                     os.system('clear')
  205.                     keyboard_color_two_fun(building_run)
  206.                 elif redo_keyboard_section == '5':
  207.                     os.system('clear')
  208.                     keyboard_switch_fun(building_run)
  209.                 elif redo_keyboard_section == '6':
  210.                     os.system('clear')
  211.                     keyboard_switch_fun(building_run)
  212.                 elif redo_keyboard_section == '7':
  213.                     os.system('clear')
  214.                     finish_custom_keyboard()
  215.  
  216.             choice_redo_custom_keyboard = raw_input("Would you like to change any of the above settings? Y/N)\n> ")
  217.             if choice_redo_custom_keyboard in ys:
  218.                 redo_custom_keyboard(building_run)
  219.             elif choice_redo_custom_keyboard in ns:
  220.                 def finish_custom_keyboard():
  221.                     custom_keyboard_name = raw_input("What would you like to name this keyboard?\n> ")
  222.                     shopping_cart_money + custom_keyboard_cost
  223.                     shopping_cart.append(custom_keyboard_name)
  224.                     os.system('clear')
  225.                     keyboard_store()
  226.                 finish_custom_keyboard()
  227.    
  228.         print "Welcome to the Keyboard Builder! This is a step by step process that gets you the perfect keyboard for your hands at a price your wallet can smile at!"
  229.         time.sleep(1)
  230.         keyboard_size_fun(1)
  231.        
  232.  
  233.     def purchase_prebuilt(): # Option 3
  234.         prebuilt_purchase_choice = raw_input("""
  235. We have these keyboards in stock right now:
  236.        
  237.    1. Razer Blackwidow Chroma: $169.99
  238.    2. Logitech g810: $159.99
  239.    3. Corsair K70 RGB: 169.99
  240.        
  241.    4. Return to options
  242.        
  243. You have $%s in your wallet, what do you want to add to your cart?\n> """ % money_in_wallet)
  244.         if prebuilt_purchase_choice == '1':
  245.             shopping_cart.append('Razer Blackwidow Chroma')
  246.             shopping_cart_money + 169.99
  247.             return_to_menu()
  248.         elif prebuilt_purchase_choice == '2':
  249.             shopping_cart.append('Logitech g810')
  250.             shopping_cart_money + 159.99
  251.             return_to_menu()
  252.         elif prebuilt_purchase_choice == '3':
  253.             shopping_cart.append('Corsair K70')
  254.             shopping_cart_money + 166.99
  255.             return_to_menu()
  256.         elif prebuilt_purchase_choice == '4':
  257.             os.system('clear')
  258.             store_options()
  259.         else:
  260.             print "That's not an option!"
  261.             os.system('clear')
  262.             purchase_prebuilt()
  263.  
  264.     def return_to_menu():
  265.             return_to_menu = raw_input("Would you like to purchase anything else? (Y/N)")
  266.             if return_to_menu in ys:
  267.                 os.system('clear')
  268.                 purchase_prebuilt()
  269.             elif return_to_menu in ns:
  270.                 os.system('clear')
  271.                 keyboard_store()
  272.             else:
  273.                 print "I'm going to take that as a no."
  274.                 os.system('clear')
  275.                 keyboard_store()
  276.  
  277.     def transaction_number_generator():
  278.         global transaction_number # can be acessed in other functions
  279.         letter_one   = random.choice(['a','b','c','d','e','f','g'])
  280.         letter_two   = random.choice(['a','b','c','d','e','f','g'])
  281.         letter_three = random.choice(['a','b','c','d','e','f','g'])
  282.         number_one   = random.choice(['1','2','3','4','5','6','7','8','9','0'])
  283.         number_two   = random.choice(['1','2','3','4','5','6','7','8','9','0'])
  284.         transaction_number = "%s%s%s%s%s" % (letter_one,letter_two,number_one,letter_three,number_two)
  285.  
  286.     def checkout():
  287.         checkout_choice = raw_input(""" Your current cart contains %s and you have $%s in your wallet. Your total comes out to %s, would you like to:
  288.    1. Complete the Purchase
  289.    2. Clear your cart
  290.    3. Return to main menu
  291.    
  292.    > """ % (shopping_cart, money_in_wallet, shopping_cart_money) )
  293.    
  294.         if checkout_choice == '1':
  295.             after_transaction_money = money_in_wallet - shopping_cart_money
  296.             if after_transaction_money >= 0:
  297.                 print "Purchase complete, enjoy your item(s). The remainder is %s. Come again soon! \n Transaction Number: %s" % (after_transaction_money, transaction_number)
  298.                 return
  299.         elif checkout_choice == '2':
  300.             shopping_cart = []
  301.             print "Your cart has been cleared, returning to menu."
  302.             time.sleep(2)
  303.             os.system('clear')
  304.             store_menu()
  305.         elif checkout_choice == '3':
  306.             os.system('clear')
  307.             store_menu()
  308.  
  309.     store_menu()
  310.  
  311. keyboard_store()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement