-4
下記のコードで助けが必要です。基本的に口座名義人の名前と、ピンがプログラムに入力された時の残高を印刷するのに必要です。また、プログラムからアカウントを追加したり削除したりする機能を実装する方法についてアドバイスがあれば、どんな助力も大歓迎です。 enter code here
Python 3で銀行口座を作る
class BankAccount:
# constructor or initializer
def __init__(self, name, money, pin):
self.__name = name
self.__balance = money # __balance is private now, so it is only accessible inside the class
self.__pin = pin
def pincheck(self):
pin = input("Enter Pin")
if pin == self.__pin
return True
else:
print("Error try again")
def deposit(self, money):
self.__balance += money
def withdraw(self, money):
if self.__balance > money :
self.__balance -= money
return money
else:
return "Insufficient funds"
def checkbalance(self):
return self.__balance
b1 = BankAccount('Obi Ezeakachi', 5000, 1111)
b2 = BankAccount('Tasha St.Patrick', 80000, 2222)
b3 = BankAccount('Tommy Egan', 7000, 3333)
d1 = 0
d2 = 0
d3 = 0
print("Obi Ezeakachi: £",b1.checkbalance())
y1 = int(input("Enter 1 if you want to make a withdrawal, enter 2 if you don't"))
if y1 == 1:
w1= int(input("How much do you want to withdraw"))
print("Withdrawal: £",b1.withdraw(w1))
else:
d1= int(input("How much do you want to deposit"))
b1.deposit(d1)
print("Current Balance:",b1.checkbalance())
print("Tasha St.Patrick:",b2.checkbalance())
y1 = int(input("Enter 1 if you want to make a withdrawal, enter 2 if you don't"))
if y1 == 1:
w2= int(input("How much do you want to withdraw"))
print(b2.withdraw(w2))
else:
d2= int(input("How much do you want to deposit"))
b2.deposit(d2)
print("Tommy Egan:",b3.checkbalance())
y1 = int(input("Enter 1 if you want to make a withdrawal, enter 2 if you don't"))
if y1 == 1:
w3= int(input("How much do you want to withdraw"))
print("Withdrawal:",b3.withdraw(w3))
else:
d3= int(input("How much do you want to deposit"))
b3.deposit(d3)
print("Current Balance:",b3.checkbalance())
反転したカンマを追加するのを忘れました。その名前をコピーしてコピーします。 –
申し訳ありません私はまだpythonに新しいです、あなたは私にjsonファイルが何であるかを説明することができます、私はまた、ピンチェッカーを機能させるつもりでした。しかし、ピンを確認して、その機能を口座の入出金を行うコードとどのようにリンクさせるべきかを確認してください。 –
jsonについては、https://www.w3schools.com/js/js_json_intro.asp –