Guest User

Python Finals 01/16/16 Shea

a guest
Jan 16th, 2016
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.07 KB | None | 0 0
  1. #Shea and Roses
  2. from random import choice #imports
  3. from string import ascii_uppercase
  4. wallet= 1000 #given amount
  5.  
  6. def RBUK_purchase(): #Sets global for keyboard
  7.   global wallet
  8.   wallet=wallet-99.99
  9.   print "Your tansaction id is:"
  10.   print(''.join(choice(ascii_uppercase) for i in range(12)))#Generates random id
  11.  
  12. def RM_purchase(): #Sets global for mouse
  13.   global wallet
  14.   wallet=wallet-69.99
  15.   print "Your tansaction id is:"
  16.   print(''.join(choice(ascii_uppercase) for i in range(12)))
  17.  
  18. def Monitor_purchase(): #Sets global for monitor
  19.   global wallet
  20.   wallet=wallet-349.99
  21.   print "Your tansaction id is:"
  22.   print(''.join(choice(ascii_uppercase) for i in range(12)))
  23.  
  24. def motherboard_purchase(): #Sets global for motherboard
  25.   global wallet
  26.   wallet=wallet-136.99
  27.   print "Your tansaction id is:"
  28.   print(''.join(choice(ascii_uppercase) for i in range(12)))
  29.  
  30. def cpu_purchase(): #Sets global for cpu
  31.   global wallet
  32.   wallet=wallet-419.50
  33.   print "Your tansaction id is:"
  34.   print(''.join(choice(ascii_uppercase) for i in range(12)))
  35.  
  36. def leave():
  37.   print "Thank you for shopping at Newegg; have a great day!"
  38.  
  39. def gpu_purchase(): #Sets global for gpu
  40.   global wallet
  41.   wallet=wallet-209.99
  42.   print "Your tansaction id is:"
  43.   print(''.join(choice(ascii_uppercase) for i in range(12)))
  44.  
  45. def fan_purchase(): #Sets global for fan
  46.   global wallet
  47.   wallet=wallet-192.99
  48.   print "Your tansaction id is:"
  49.   print(''.join(choice(ascii_uppercase) for i in range(12)))
  50.  
  51. def case_purchase(): #Sets global for case
  52.   global wallet
  53.   wallet=wallet-189.99
  54.   print "Your tansaction id is:"
  55.   print(''.join(choice(ascii_uppercase) for i in range(12)))
  56.  
  57. def ssd_purchase(): #Sets global for ssd
  58.   global wallet
  59.   wallet=wallet-45.99
  60.   print "Your tansaction id is:"
  61.   print(''.join(choice(ascii_uppercase) for i in range(12)))
  62.  
  63. def os_purchase(): #Sets global for os
  64.   global wallet
  65.   wallet=wallet-100
  66.   print "Your tansaction id is:"
  67.   print(''.join(choice(ascii_uppercase) for i in range(12)))
  68.  
  69. def print_wallet():
  70.   print "Your account balance is %d!" % wallet
  71.  
  72. def list_inventory():
  73.   print "To purchase an item, please input the number next to it. In stock we have:\n1.Razer Blackwidow Ultimate 2016 Mechanical Gaming Keyboard for 99.99\n2.Razer DeathAddar Chroma for 69.99\n3.Acer KBlack 23.6in. 4ms (GTG) Widescreen LED Backlight LCD Monitor, IPS Panel 300 cd/m2 100,000,000:1 Built-in Speakers for 349.99\n4.GIGABYTE LGA 1150 Intel Z97 HDMI SATA 6Gb/s USB 3.0 ATX Intel Motherboard for 136.99\n5.Intel Core i7-6700K 8M Skylake Quad-Core 4.0 GHz LGA 1151 91W Desktop Processor Intel® HD Graphics 530 for 419.50\n.6.EVGA GeForce GTX 960 2GB SSC GAMING w/ACX 2.0+, Whisper Silent Cooling Graphics Card for 209.99\n7.CISCO Fan Module with Back to Front Airflow for Nexus 5596UP for 192.99\n7. IN WIN 805 GOLD / Black Aluminum / Tempered Glass ATX Mid Tower Computer Case Compatible with ATX 12V/EPS (up to 220mm) Power Supply for 189.99\n9.Patriot Blaze 2.5\" 120GB SATA III Internal Solid State Drive (SSD) for 45.99\n10.Microsoft Windows 10 Home - 64-bit - OEM for 100.00"
  74.   buy= raw_input(">")
  75.   if wallet>=45.99:
  76.     if buy=="1":
  77.       RBUK_purchase()
  78.       print_wallet()
  79.       welcome_screen()
  80.     elif buy=="2":
  81.       RM_purchase()
  82.       print_wallet()
  83.       welcome_screen()
  84.     elif buy=="3":
  85.       Monitor_purchase()
  86.       print_wallet()
  87.       welcome_screen()
  88.     elif buy=="4":
  89.       motherboard_purchase()
  90.       print_wallet()
  91.       welcome_screen()
  92.     elif buy=="5":
  93.       cpu_purchase()
  94.       print_wallet()
  95.       welcome_screen()
  96.     elif buy=="6":
  97.       gpu_purchase()
  98.       print_wallet()
  99.       welcome_screen()
  100.     elif buy=="7":
  101.       fan_purchase()
  102.       print_wallet()
  103.       welcome_screen()
  104.     elif buy=="8":
  105.       case_purchase()
  106.       print_wallet()
  107.       welcome_screen()
  108.     elif buy=="9":
  109.       ssd_purchase()
  110.       print_wallet()
  111.       welcome_screen()
  112.     elif buy=="10":
  113.       os_purchase()
  114.       print_wallet()
  115.       welcome_screen()
  116.   else:
  117.     print "You do not have enough money to purchase anything in this store, thank you for coming!"
  118.     leave()
  119.  
  120. allowed_users=['ADMIN']#username
  121. acceptedpassword=['admin']#password
  122.  
  123. def enterusername():#username prompt
  124.   username=raw_input("Please enter your username\n>")
  125.   if username in allowed_users:
  126.     print "User Reconigized"
  127.     enterpassword()
  128.   else:
  129.     print "User unknown"
  130.     enterusername()
  131.  
  132. def enterpassword():#password prompt
  133.   password=raw_input("Please enter password for user \'ADMIN\'\n>")
  134.   if password in acceptedpassword:
  135.     welcome_screen()
  136.   else:
  137.     print "Incorrect password, please re-enter credentials."
  138.     enterpassword()
  139.  
  140. def welcome_screen():
  141.   if wallet>0:
  142.     print "Welcome to Newegg.com! Would you like to see our inventory or exit the store?Type 1 to see our inventory, 2 to exit."
  143.     see_or_leave=raw_input(">")
  144.     if see_or_leave == "1":
  145.       list_inventory()
  146.     else:
  147.       leave()
  148.   else:
  149.     print "You are in debt and must exit the store, your last order has been canceled."
  150.     leave()
  151.  
  152. enterusername()
Add Comment
Please, Sign In to add comment