Guest User

Final Project

a guest
Jan 15th, 2016
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 7.23 KB | None | 0 0
  1. #Michael Richards and Luis Espinal
  2. import string
  3. import random
  4.  
  5. def destination():
  6.   print "What would you like to do?\n\t1) Browse Inventory\n\t2) Leave"
  7.   destination=raw_input()
  8.   if destination=="1":
  9.     inventory()
  10.   if destination=="2":
  11.       leave()
  12.  
  13. def leave():
  14.   print "Thanks for shopping here!"
  15.   exit()
  16.  
  17. balance=1000
  18. cart=[] #represents empty cart will be adding bought items into it
  19. items = ['1) Razer keyboard-$160','2) Corsair mouse-$40','3) Samsung monitor-$200','4) MSI motherboard- $180','5)AMD CPU-$180','6) ASUS graphics card-$230','7) HIS system fans- $160','8) Phanteks computer case-$90','9)Seagate Hard Drive-110','10) Microsoft Windows 7 operating system-$140']
  20. item1=160
  21. item2=40
  22. item3=200
  23. item4=180
  24. item5=180
  25. item6=230
  26. item7=160
  27. item8=90
  28. item9=110
  29. item10=140
  30.  
  31.  
  32. def inventory():
  33.   global balance
  34.   while balance>39:
  35.     global items
  36.     global item1,item2,item3,item4,item5,item6,item7,item8,item9,item10
  37.     global cart
  38.     from random import choice #to print random code
  39.     from string import ascii_uppercase
  40.     print items
  41.     print "What would you like to Buy?"
  42.     buy=raw_input()
  43.     if buy=="1" and balance>159:
  44.       balance=balance-160
  45.       print "You have bought the Razer Keyboard for $160 and your balance is now $%d"% (balance)
  46.       print 'Your Transaction ID for this item is:'
  47.       print(''.join(choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789') for i in range(12))) #prints random code
  48.       cart.append(item1) #adds item into checkoout
  49.       items[0]='Out of Stock'
  50.       print "Would you like to\n 1) Keep Shopping 2) Checkout and Exit"
  51.       x=raw_input()
  52.       if x=="1":
  53.         inventory()
  54.       if x=="2":
  55.         checkout()
  56.    
  57.     if buy=="2" and balance>39:
  58.       balance=balance-40
  59.       print "You have bought the Corsair Mouse for $40 and your balance is now $%d"% (balance)
  60.       print 'Your Transaction ID for this item is:'
  61.       print(''.join(choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789') for i in range(12)))
  62.       cart.append(item2)
  63.       items[1]='Out of Stock'
  64.  
  65.       print "Would you like to\n 1) Keep Shopping 2) Checkout and Exit"
  66.       x=raw_input()
  67.       if x=="1":
  68.         inventory()
  69.       if x=="2":
  70.         checkout()  
  71.    
  72.     if buy=="3" and balance>199:
  73.       balance=balance-200
  74.       print "You have bought the Samsung Monitor for $200 and your balance is now $%d"% (balance)
  75.       print 'Your Transaction ID for this item is:'
  76.       print(''.join(choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789') for i in range(12)))
  77.       cart.append(item3)
  78.       items[2]='Out of Stock'
  79.       print "Would you like to\n 1) Keep Shopping 2) Checkout and Exit"
  80.       x=raw_input()
  81.       if x=="1":
  82.         inventory()
  83.       if x=="2":
  84.         checkout()  
  85.    
  86.     if buy=="4" and balance>179:
  87.       balance=balance-180
  88.       print "You have bought the MSI Motherboard for $180 and your balance is now $%d"% (balance)
  89.       print 'Your Transaction ID for this item is:'
  90.       print(''.join(choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789') for i in range(12)))
  91.       cart.append(item4)
  92.       items[3]='Out of Stock'
  93.       print "Would you like to\n 1) Keep Shopping 2) Checkout and Exit"
  94.       x=raw_input()
  95.       if x=="1":
  96.         inventory()
  97.       if x=="2":
  98.         checkout()  
  99.    
  100.     if buy=="5" and balance>179:
  101.       balance=balance-180
  102.       print "You have bought the AMD CPU for $180 and your balance is now $%d"% (balance)
  103.       print 'Your Transaction ID for this item is:'
  104.       print(''.join(choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789') for i in range(12)))
  105.       cart.append(item5)
  106.       items[4]='Out of Stock'
  107.       print "Would you like to\n 1) Keep Shopping 2) Checkout and Exit"
  108.       x=raw_input()
  109.       if x=="1":
  110.         inventory()
  111.       if x=="2":
  112.         checkout()  
  113.    
  114.     if buy=="6" and balance>229:
  115.       balance=balance-230
  116.       print "You have bought the ASUS Graphics Card for $230 and your balance is now $%d"% (balance)
  117.       print 'Your Transaction ID for this item is:'
  118.       print(''.join(choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789') for i in range(12)))
  119.       cart.append(item6)
  120.       items[5]='Out of Stock'
  121.       print "Would you like to\n 1) Keep Shopping 2) Checkout and Exit"
  122.       x=raw_input()
  123.       if x=="1":
  124.         inventory()
  125.       if x=="2":
  126.         checkout()  
  127.    
  128.     if buy=="7" and balance>159:
  129.       balance=balance-160
  130.       print "You have bought the HIS System Fans for $160 and your balance is now $%d"% (balance)
  131.       print 'Your Transaction ID for this item is:'
  132.       print(''.join(choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789') for i in range(12)))
  133.       cart.append(item7)
  134.       items[6]='Out of Stock'
  135.       print "Would you like to\n 1) Keep Shopping 2) Checkout and Exit"
  136.       x=raw_input()
  137.       if x=="1":
  138.         inventory()
  139.       if x=="2":
  140.         checkout()  
  141.    
  142.     if buy=="8" and balance>89:
  143.       balance=balance-90
  144.       print "You have bought the Phanteks Computer Case for $90 and your balance is now $%d"% (balance)
  145.       print 'Your Transaction ID for this item is:'
  146.       print(''.join(choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789') for i in range(12)))
  147.       cart.append(item8)
  148.       items[7]='Out of Stock'
  149.       print "Would you like to\n 1) Keep Shopping 2) Checkout and Exit"
  150.       x=raw_input()
  151.       if x=="1":
  152.         inventory()
  153.       if x=="2":
  154.         checkout()  
  155.    
  156.     if buy=="9" and balance>109:
  157.       balance=balance-110
  158.       print "You have bought the CardSeagate Hard Drive for $110 and your balance is now $%d"% (balance)
  159.       print 'Your Transaction ID for this item is:'
  160.       print(''.join(choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789') for i in range(12)))
  161.       cart.append(item9)
  162.       items[8]='Out of Stock'
  163.       print "Would you like to\n 1) Keep Shopping 2) Checkout and Exit"
  164.       x=raw_input()
  165.       if x=="1":
  166.         inventory()
  167.       if x=="2":
  168.         checkout()
  169.    
  170.     if buy=="10" and balance>139:
  171.       balance=balance-140
  172.       print "You have bought the Microsoft Windows 7 Operating System for $140 and your balance is now $%d"% (balance)
  173.       print 'Your Transaction ID for this item is:'
  174.       print(''.join(choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789') for i in range(12)))
  175.       cart.append(item10)
  176.       items[9]='Out of Stock'
  177.       print "Would you like to\n 1) Keep Shopping 2) Checkout and Exit"
  178.       x=raw_input()
  179.       if x=="1":
  180.         inventory()
  181.       if x=="2":
  182.         checkout()  
  183.     else:
  184.       print "Sorry not enough money"
  185.       checkout()
  186.  
  187.  
  188. def checkout():
  189.   global cart
  190.   global balance
  191.   cartsum=sum(cart)
  192.   total=(11+(cartsum*.07)+cartsum)
  193.   tax=(cartsum*.07)
  194.   print "The price of your order is $%d. Shipping is $11 and tax is $%d.\nYour total price with tax and shipping is $%d"% ((1000-balance), tax, total)
  195.   balance=(balance-(cartsum*.07)-11)
  196.   print "Your balance is now $%d"% balance
  197.   print "Thanks for Shopping!"
  198.   exit()
  199.  
  200.  
  201.  
  202.    
  203.    
  204.  
  205. print "Hi Welcome to the store!\nEnter your username and password to begin!"
  206. grantedu=['ADMIN']
  207. grantedp=['admin']
  208. username=raw_input(">")
  209. if username in grantedu:
  210.   password=raw_input(">")
  211.   if password in grantedp:
  212.     print "Thanks for logging in!\n Your balance is $%d."% balance
  213.     destination()
Add Comment
Please, Sign In to add comment