Exemplo n.º 1
0
def welcome(): #Will repeat this until user data is proper
  bank.update() #Loads file (so does bank.getInfo, but that is a side-effect)
  print("Welcome to the bank!")
  print("Please enter your name as it appears on your bank card (Just pretend),")
  print("or type New to make a new account")
  name = input() #Get full name (not needed :P Just need first)
  try:
    commandList[name.lower()] #Get the key error immediately to get extra functions
    num = 0 #To prevent reference before assignment errors
    if name.lower() == "final": #Delete all files and exit
      system("if exist Accounts (rd /q /s %s)" % saveFolder)
      system("if exist %s (del /q %s)" % (bank.saveFile,bank.saveFile))
      name = "quit" #Exit after delete
    if name.lower() == "quit": #Exit nicely
      exit()
    if name.lower() == "master": #Get bank stats
      print("Master Balance: %.2f" % (bank.getInfo()[1]) )
      print("Total Transactions: %d\n" % (bank.getInfo()[3]) )
      tab = ">> "
      for _, a in bank.master.accounts.items(): #Super sneaky hax
        print("%sName: %s\n%s%sBalance: %.2f\n" % (tab, a[0],tab[:-1],tab, a[1]))
    if name.lower() == "master loans":
      for a, b in enumerate(bank.master.loans):
        if b[1] > 0:
          print("ID: %2d | Account Linked: %s | Outstanding: %.2f" % (a+1,b[0][0],b[1]))
    if name.lower() == "new":
      while True: #Repeat loop in case of invalid new name
        print("Ok, to start, what is your full name?")
        name = input()
        print("How much money are you depositing initially?")
        amnt = input()
        while not (isinstance(amnt,float)): #This makes sure it is actually a number, then rounds it to two places
          try:
            amnt = round(float(amnt),2)
          except ValueError:
            print("Number not recognized, try again")
            amnt = input()
        name, num = bank.register(name, amnt) #Registers the new user, returns their bank ID number
        if name != False:
          break
        else:
          cls()
          print("Invalid Name")
      print("Thank you, %s, your new bank number is %d" % (name, num))
      print("Keep this information somewhere you will remember")
      bankCard(name,num)
    input("Press Enter to continue...") #This is out of loops, will run for all
  except KeyError:
    print("What is your bank ID number? (type '0' to go back)") #Need ID number as well
    num = inputInt("Number not recognized, try again")
  accountName = bank.getName(name,num)
  return bank.exists(accountName,num), accountName #Returns that the account exists, as well as the account name (e.g. "default0001")
Exemplo n.º 2
0
 def rpc_register(self, username):
     return bank.register(username)
Exemplo n.º 3
0
#Bank is done :)
#I will go through some examples
#The bank functions never print anything, so you will have to do that on your own
#Do note that each person acts as both an object, and a part of the master table, you can use them both ways
def printSleep(words, time=1):  #For simulated UI
    print(words)
    sleep(time)


def func(words, func, *params):
    print(words)
    return func(*params)


print(bank.register("Civil",
                    100))  #I have 100 dollars, this returns my name and number
print(bank.register("Bill", 200))  #Bill has 200 dollars
print(bank.getInfo())  #Gets bank stats
print(bank.getInfo("civil0001"))  #They "proper" way to get the info
print(bank.getInfo(bank.getName("Civil", 1)))  #Easier way
print(bank.getInfo(bank.getNum("Civil")))  #Alternate way, less reliable


def UI_Test():
    printSleep("What is your name? ")
    name = "Bill"
    printSleep(name)
    printSleep(bank.getInfo(bank.getNum(name)),
               3)  #To show how this is implemented
    printSleep("What is you name and number? ")
    name_number = "Bill 0002"
Exemplo n.º 4
0
import bank as bank
from time import sleep

#Bank is done :)
#I will go through some examples
#The bank functions never print anything, so you will have to do that on your own
#Do note that each person acts as both an object, and a part of the master table, you can use them both ways
def printSleep(words, time = 1): #For simulated UI
  print(words)
  sleep(time)
def func(words,func,*params):
  print(words)
  return func(*params)


print(bank.register("Civil",100)) #I have 100 dollars, this returns my name and number
print(bank.register("Bill", 200)) #Bill has 200 dollars
print(bank.getInfo()) #Gets bank stats
print(bank.getInfo("civil0001")) #They "proper" way to get the info
print(bank.getInfo(bank.getName("Civil",1))) #Easier way
print(bank.getInfo(bank.getNum("Civil"))) #Alternate way, less reliable
def UI_Test():
  printSleep("What is your name? ")
  name = "Bill"
  printSleep(name)
  printSleep(bank.getInfo(bank.getNum(name)),3) #To show how this is implemented
  printSleep("What is you name and number? ")
  name_number = "Bill 0002"
  printSleep(name_number)
  name, number = name_number.split(" ")
  printSleep(bank.getInfo(name.lower()+number),2) #If you have the name and number, you can do bank.getName by yourself
Exemplo n.º 5
0
 def rpc_register(self, username):
     bank.register(username)
Exemplo n.º 6
0
 def rpc_register(self, username):
   return bank.register(username)