class Account:
balance = int(0)
def add(self, amount, balance):
erroramount, balance = error(amount, balance)
answer = fred.balance - int(withdraw)
trans, more = transaction(trans, more)
fred.summary(fred.balance)
return answer
def minus(self, amount, balance):
amount, balance = error(amount, balance)
answer = fred.balance + int(deposit)
trans, more = transaction(trans, more)
return answer
def summary(self, balance):
print("Your current balance is: "+str(balance)
def transaction(trans, more):
more = input(" Would you like to make more transactions ")
if more == "yes":
print (fred.summary)
print ("1) Withdraw")
print ("2) Deposit")
print ("3) Create new savings Account")
print ("4) Deposit money into existing account")
print ("5) Withdraw money from existing account")
trans= input(" Which option would you like to choose? ")
elif more == "no":
print (" Signing off ")
return trans, more
def error(amount, balance):
while int(amount) < 1 or int(amount) > int(balance):
print (" Error insufficent funds ")
int(input(" Enter a valid number "))
name = ("fred")
password = ("8860")
uName = input(" Enter your name ")
uPass = input(" Enter a password ")
if uName != name or uPass != password:
print (" Error invalid information ")
uName = input(" Enter your name ")
uPass = input(" Enter a password ")
elif uPass == name and uPass == password:
fred = Account()
fred.balance = int(100000)
print (balance)
trans, more = transaction(trans, more)
if trans == "1":
amount = input(" How much money would you like to withdraw? ")
withdraw = fred.add(fred.balance)
print (withdraw)
if trans == "2":
amount = input("How much money would you like to deposit? ")
while deposit < 1:
print (" Error insufficent funds ")
amount = input(" How much money would you like to deposit? ")
else:
balance = int(balance) + int(amount)
fred.summary(fred.balance)
trans, more = transaction(trans, more)
if trans == "3":
nameNew = input(" Enter a name ")
passNew = input(" Enter a password ")
nameAgain = input(" Reenter the name ")
passAgain = input(" Reenter the password ")
while nameNew != nameAgain or passNew != passAgain:
print (" Error name or password didn't match ")
nameNew = input(" Enter a name ")
passNew = input(" Enter a password ")
nameAgain = input(" Reenter the name ")
passAgain = input(" Reenter the password ")
else:
nameNew = Account()
print (" Congragulations, you created an account for " + str(nameNew))
trans, more = transaction(trans, more)
if trans == "4":
depositNew = input(" How much money would you like to deposit?")
while int(depositNew) > int(balance) or int(depositNew) < int(1):
print (" Error insufficent funds ")
depositNew = input(" How much money would you like to deposit?")
else:
depositNew = int(depositNew)
nameNew.balance = int(deposit) + int(nameNew.balance)
fred.balance = int(fred.balance)-int(depositNew)
fred.summary(fred.balance)
nameNew.summary(nameNew.balance)
print (nameNew + "'s balance is " + nameNewBal)
trans, more = transaction(trans, more)
if trans == "5":
withdrawNew = input(" How much money would you like to withdraw? ")
while int(withdrawNew) > int(nameNewBal):
print (" Error insufficent funds ")
withdrawNew = input(" How much money would you like to deposit?")
else:
withdrawNew = int(depositNew)
nameNew.balance = int()
nameNew.balance = int(nameNew.balance) - int(withdrawNew)
fred.balance = int(fred.balance) + int(withdrawNew)
print ("Your current balance is " + fred.balance+ " " +nameNew + "'s balance is " + nameNew.balance)
trans, more = transaction(trans, more)
我确定他们一直都是错误,但我只是在课堂和调用函数的最顶层寻求帮助。如果我注释掉该区域,程序将至少启动,否则我会收到语法错误。请帮我弄清楚我是否正确调用函数并修复语法错误,谢谢。
答案 0 :(得分:2)
你错过了一个结尾)
def summary(self, balance):
print("Your current balance is: "+str(balance))