Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import os
- import time
- global money_in_wallet
- global dashes
- global shopping_cart
- global shopping_cart_money
- global ys
- global ns
- shopping_cart = []
- shopping_cart_money = 0
- money_in_wallet = random.choice([200,250,300,350])
- ys = ['Y', 'y']
- ns = ['N', 'n']
- def keyboard_store():
- dashes = '-' * 30
- def store_menu():
- print """
- %s
- Welcome to the Keyboard Shop!
- %s\n
- """ % (dashes, dashes)
- store_options()
- def store_options():
- store_option_choice = raw_input("""
- What would you like to do?
- 1. Build a New Keyboard
- 2. Buy Prebuilt Keyboards
- 3. Checkout\n\n > """)
- if store_option_choice == '1':
- os.system('clear')
- build_keyboard()
- elif store_option_choice == '2':
- os.system('clear')
- purchase_prebuilt()
- elif store_option_choice == '3':
- checkout()
- else:
- print "That's not an option!"
- time.sleep(1)
- os.system('clear')
- keyboard_store()
- def build_keyboard(): # Option 1
- custom_keyboard_cost = 0
- def keyboard_size_fun(building_run):
- global keyboard_size
- 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> ")
- if keyboard_size == '1':
- keyboard_size = '40%'
- custom_keyboard_cost + 49.99
- while building_run > 0: # While loop determining if it is first build or in editing stage
- keyboard_switch_fun(building_run)
- else:
- build_keyboard_finalize(building_run)
- elif keyboard_size == '2':
- keyboard_size = '60%'
- custom_keyboard_cost + 59.99
- while building_run > 0:
- keyboard_switch_fun(building_run)
- else:
- build_keyboard_finalize(building_run)
- elif keyboard_size == '3':
- keyboard_size = '80%'
- custom_keyboard_cost + 69.99
- while building_run > 0:
- keyboard_switch_fun(building_run)
- else:
- build_keyboard_finalize(building_run)
- elif keyboard_size == '4':
- keyboard_size = '100%'
- custom_keyboard_cost + 79.99
- while building_run > 0:
- keyboard_switch_fun(building_run)
- else:
- build_keyboard_finalize(building_run)
- else:
- print "That's not an option"
- os.system('clear')
- keyboard_size_fun(building_run)
- def keyboard_switch_fun(building_run):
- global keyboard_switch
- print custom_keyboard_cost
- 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> ")
- if keyboard_switch == '1':
- keyboard_switch = 'Cherry MX Blue'
- custom_keyboard_cost + 10
- while building_run > 0: # While loop determining if it is first build or in editing stage
- keyboard_color_one_fun(building_run)
- else:
- build_keyboard_finalize(building_run)
- elif keyboard_switch == '2':
- keyboard_switch = 'Cherry MX Red'
- custom_keyboard_cost + 8
- while building_run > 0:
- keyboard_color_one_fun(building_run)
- else:
- build_keyboard_finalize(building_run)
- elif keyboard_switch == '3':
- keyboard_switch = 'Cherry MX Brown'
- custom_keyboard_cost + 9
- while building_run > 0:
- keyboard_color_one_fun(building_run)
- else:
- build_keyboard_finalize(building_run)
- elif keyboard_switch == '4':
- keyboard_switch = 'Cherry MX Green'
- custom_keyboard_cost + 12
- while building_run > 0:
- keyboard_color_one_fun(building_run)
- else:
- build_keyboard_finalize(building_run)
- else:
- print "That's not an option"
- os.system('clear')
- keyboard_switch_fun(building_run)
- def keyboard_color_one_fun(building_run):
- global keyboard_color_one
- 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> ")
- while building_run > 0:
- keyboard_color_two_fun(building_run)
- else:
- build_keyboard_finalize(building_run)
- def keyboard_color_two_fun(building_run):
- global keyboard_color_two
- keyboard_color_two = raw_input("Next is the secondary color, this will be the front plate right next to the keycaps.\n> ")
- while building_run > 0:
- keycap_color_fun(building_run)
- else:
- build_keyboard_finalize(building_run)
- def keycap_color_fun(building_run):
- global keycap_color
- keycap_color = raw_input("Finally for colors is the keycaps, these are what you will be looking at the most so choose wisely\n> ")
- while building_run > 0:
- keyboard_RGB_fun(building_run)
- else:
- build_keyboard_finalize(building_run)
- def keyboard_RGB_fun(building_run):
- global keyboard_RGB
- 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> ")
- if keyboard_RGB in ys:
- keyboard_RGB = "Yes"
- custom_keyboard_cost + 20
- build_keyboard_finalize(building_run)
- elif keyboard_RGB in ns:
- keyboard_RGB = "No"
- build_keyboard_finalize(building_run)
- def build_keyboard_finalize(building_run):
- building_run + 1
- print """
- Here is what you chose:
- 1. Keyboard Size: %s
- 2. Keyboard Switch: %s
- 3. Keyboard Base Color: %s
- 4. Keyboard Plate Color: %s
- 5. Keycap Color: %s
- 6. Keyboard RGB: %s
- And the total for your keyboard is $%s
- """ % (keyboard_size, keyboard_switch, keyboard_color_one, keyboard_color_two, keycap_color, keyboard_RGB, custom_keyboard_cost)
- def redo_custom_keyboard(building_run):
- building_run - 1
- redo_keyboard_section = raw_input("""
- which section do you want to start at?
- 1. Keyboard Size:
- 2. Keyboard Switch:
- 3. Keyboard Base Color:
- 4. Keyboard Plate Color:
- 5. Keycap Color:
- 6. Keyboard RGB:
- 7. Cancel""")
- if redo_keyboard_section == '1':
- os.system('clear')
- keyboard_size_fun(building_run)
- elif redo_keyboard_section == '2':
- os.system('clear')
- keyboard_switch_fun(building_run)
- elif redo_keyboard_section == '3':
- os.system('clear')
- keyboard_color_one_fun(building_run)
- elif redo_keyboard_section == '4':
- os.system('clear')
- keyboard_color_two_fun(building_run)
- elif redo_keyboard_section == '5':
- os.system('clear')
- keyboard_switch_fun(building_run)
- elif redo_keyboard_section == '6':
- os.system('clear')
- keyboard_switch_fun(building_run)
- elif redo_keyboard_section == '7':
- os.system('clear')
- finish_custom_keyboard()
- choice_redo_custom_keyboard = raw_input("Would you like to change any of the above settings? Y/N)\n> ")
- if choice_redo_custom_keyboard in ys:
- redo_custom_keyboard(building_run)
- elif choice_redo_custom_keyboard in ns:
- def finish_custom_keyboard():
- custom_keyboard_name = raw_input("What would you like to name this keyboard?\n> ")
- shopping_cart_money + custom_keyboard_cost
- shopping_cart.append(custom_keyboard_name)
- os.system('clear')
- keyboard_store()
- finish_custom_keyboard()
- 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!"
- time.sleep(1)
- keyboard_size_fun(1)
- def purchase_prebuilt(): # Option 3
- prebuilt_purchase_choice = raw_input("""
- We have these keyboards in stock right now:
- 1. Razer Blackwidow Chroma: $169.99
- 2. Logitech g810: $159.99
- 3. Corsair K70 RGB: 169.99
- 4. Return to options
- You have $%s in your wallet, what do you want to add to your cart?\n> """ % money_in_wallet)
- if prebuilt_purchase_choice == '1':
- shopping_cart.append('Razer Blackwidow Chroma')
- shopping_cart_money + 169.99
- return_to_menu()
- elif prebuilt_purchase_choice == '2':
- shopping_cart.append('Logitech g810')
- shopping_cart_money + 159.99
- return_to_menu()
- elif prebuilt_purchase_choice == '3':
- shopping_cart.append('Corsair K70')
- shopping_cart_money + 166.99
- return_to_menu()
- elif prebuilt_purchase_choice == '4':
- os.system('clear')
- store_options()
- else:
- print "That's not an option!"
- os.system('clear')
- purchase_prebuilt()
- def return_to_menu():
- return_to_menu = raw_input("Would you like to purchase anything else? (Y/N)")
- if return_to_menu in ys:
- os.system('clear')
- purchase_prebuilt()
- elif return_to_menu in ns:
- os.system('clear')
- keyboard_store()
- else:
- print "I'm going to take that as a no."
- os.system('clear')
- keyboard_store()
- def transaction_number_generator():
- global transaction_number # can be acessed in other functions
- letter_one = random.choice(['a','b','c','d','e','f','g'])
- letter_two = random.choice(['a','b','c','d','e','f','g'])
- letter_three = random.choice(['a','b','c','d','e','f','g'])
- number_one = random.choice(['1','2','3','4','5','6','7','8','9','0'])
- number_two = random.choice(['1','2','3','4','5','6','7','8','9','0'])
- transaction_number = "%s%s%s%s%s" % (letter_one,letter_two,number_one,letter_three,number_two)
- def checkout():
- 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:
- 1. Complete the Purchase
- 2. Clear your cart
- 3. Return to main menu
- > """ % (shopping_cart, money_in_wallet, shopping_cart_money) )
- if checkout_choice == '1':
- after_transaction_money = money_in_wallet - shopping_cart_money
- if after_transaction_money >= 0:
- print "Purchase complete, enjoy your item(s). The remainder is %s. Come again soon! \n Transaction Number: %s" % (after_transaction_money, transaction_number)
- return
- elif checkout_choice == '2':
- shopping_cart = []
- print "Your cart has been cleared, returning to menu."
- time.sleep(2)
- os.system('clear')
- store_menu()
- elif checkout_choice == '3':
- os.system('clear')
- store_menu()
- store_menu()
- keyboard_store()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement