Guest User

Untitled

a guest
Nov 16th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. import string
  2. import random
  3. import time
  4. lst = []
  5. lst1 = []
  6. lstDeposit = []
  7. lstWithdrawal =[]
  8. def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
  9. return ''.join(random.choice(chars) for _ in range(size))
  10.  
  11. class user:
  12. def __init__(self, name, surname, password, deposit ,withdrawal , total):
  13. self.name = name
  14. self.surname = surname
  15. self.password = password
  16. self.deposit = deposit
  17. self.withdrawal = withdrawal
  18. self.total = total
  19.  
  20. def login():
  21. user_id = input("\nIdentifier: ")
  22. User = user(input("name: "), input("surname: "), input("password: "), deposit = 0, withdrawal = 0, total = 0)
  23. lst1.append([user_id,User.name,User.surname,User.password])
  24. for i in range(len(lst)):
  25. if lst[i] == lst1[0]:
  26. print("\nAccessing the account of " + User.name + "...")
  27. time.sleep(1)
  28. print("access executed")
  29. time.sleep(1)
  30. while True:
  31. print("\nSelect an action:\nDeposit (1) \nPrint your total (2) \nWithdrawal (3)\nPrint all your withdrawals (4)\nPrint all your deposits (5) \nPrint your total (6) \nLogout (7)")
  32. action = input(":")
  33.  
  34. if action == "1":
  35. User.deposit = input("deposit: ")
  36. lstDeposit.append(User.deposit)
  37.  
  38. if action == "2":
  39. total = int(User.deposit) - int(User.withdrawal)
  40. print(total)
  41.  
  42. if action == "3":
  43. User.withdrawal = input("withdrawal: ")
  44. lstWithdrawal.append(User.withdrawal[i])
  45.  
  46. if action == "4":
  47. try:
  48. for word in lstWithdrawal:
  49. print(lstWithdrawal[i])
  50. except IndexError:
  51. print("you don't have any deposit")
  52.  
  53. if action == "5":
  54. try:
  55. for word in lstDeposit:
  56. print(lstDeposit[i])
  57. except IndexError:
  58. print("you don't have any deposit")
  59.  
  60. if action == "6":
  61. total = int(User.deposit) - int(User.withdrawal)
  62. print(total)
  63.  
  64. if action == "7":
  65. del lst1[:]
  66. start()
  67. else:
  68. print("wrong credentials")
  69. del lst1[:]
  70. start()
  71.  
  72. def makeUser():
  73. i = 1
  74. while i > 0:
  75. User = user(input("\nname: "), input("surname: "), input("password: "), deposit = 0, withdrawal = 0, total = 0)
  76. user_id = id_generator()
  77. lst.append([user_id,User.name,User.surname,User.password])
  78. time.sleep(0.5)
  79. print("\nadding new user..")
  80. time.sleep(1)
  81. print("User " + User.name + " add.")
  82. print("User identifier: " + user_id)
  83. i += 1
  84. start()
  85.  
  86. def start1():
  87. print("starting...")
  88. start()
  89.  
  90. def start():
  91. time.sleep(1.5)
  92. print("\nSelect an action:\nAdd new user (1)\nLogin (2)\nExit (3)")
  93. action = input(":")
  94. if action == "1":
  95. makeUser()
  96. elif action == "2":
  97. login()
  98. elif action == "3":
  99. print("whish you a good day")
  100. raise SystemExit
  101.  
  102. start1()
Add Comment
Please, Sign In to add comment