Ejemplo n.º 1
0
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
Ejemplo n.º 2
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")
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
#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(" ")
Ejemplo n.º 5
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"
  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
if bank.getInfo[1] == 300:
  UI_Test()
Ejemplo n.º 6
0
def header(): #At top of screen
  print("-----Current Account: %s  |  Balance: %.2f  -----" % (bank.getInfo(account)[0], bank.getInfo(account)[1]))
Ejemplo n.º 7
0
      readAllLoans()
      return bank.payLoan(account,inputInt("Invalid LoanID","What is your LoanID"),inputFloat("Invalid amount","What amount would you like to pay off?"))
  print("You have no loans outstanding")
  return False

def readAllLoans():
  check = False
  for a, b in enumerate(bank.master.loans):
    if b[0] == bank.master.accounts[account] and b[1] > 0:
      temp, check = bank.master.loans[a], True
      print("Loan #%d: %.2f outstanding out of %.2f" % (a+1, temp[1], temp[3]))
  return check or print("You have no loans") or False #If check is false, will print that and return false
  

menu = [] #Form is: text, function | All functions must return true or false
menu.append(["Check Account Info", lambda: print("Balance: %.2f, Account Interest Rate: %.2f, # of Transactions %d" % (bank.getInfo(account)[1:4])) or True])
menu.append(["Deposit Money", lambda: bank.deposit(account, inputInt("Invalid Number","How much money would you like to deposit?"))])
menu.append(["Withdraw Money", lambda: (bank.withdraw(account, inputInt("Invalid Number","How much money would you like to withdraw?")))[0]])
menu.append(["Apply for Loan", applyForLoan] )
menu.append(["Pay off Loan", payLoan])
menu.append(["Read Loan Info", readAllLoans])
menu.append(["Sign Out", lambda: "Signing Out"])

while True: #Actual program loop
  #Getting user information before we give options
  while True: #This is a makeshift "repeat ... until" loop that will go through at least once
    test, account = welcome()
    if test:
      break
    else:
      cls()