Your code has a handful of mistakes and misconceptions. I corrected some of them to get this to work ...
class Account:
'''Wells Fargo.'''
#global balance
def __init__(self, name, pin_number, balance):
self.name = name
self.pin_number = pin_number
self.balance = balance
def alter_pin(self, enter_a_pin):
'''needs work'''
'''To be used a later revision, changes a pin number.'''
ID_List = []
ID_List.append(enter_a_pin)
def ID_Pin(self):
'''needs work'''
pin = 0000
return pin
def get_balance(self, pin_number):
if pin_number == self.pin_number:
print("%s has balance: %d" % (self.name, self.balance))
else:
print("Access denied: Incorrect PIN.")
def withdraw(self,pin_number, amount):
if pin_number == self.pin_number:
self.balance -= amount
print("Withdrew %d. New Balance: %d" % (amount, self.balance))
else:
print("Access denied: Incorrect PIN.")
def deposit(self, pin_number, amount):
if pin_number == self.pin_number:
self.balance += amount
print("Deposited %d. New Balance: %d" % (amount, self.balance))
if self.balance <= 0:
print("Balance limit reached!")
else:
print("Access denied: Incorrect PIN.")
# create unique account instances ...
jimmy = Account("Jim", 0000, 100)
jimmy.get_balance(0000)
jimmy.deposit(0000, 50000)
print('-'*40)
betsy = Account("Elisabeth", 1234, 777)
betsy.get_balance(1234)
betsy.deposit(1234, 7000)
''' result ...
Jim has balance: 100
Deposited 50000. New Balance: 50100
----------------------------------------
Elisabeth has balance: 777
Deposited 7000. New Balance: 7777
'''
Note that self is a reference to the particular instance of the class.
vegaseat
DaniWeb's Hypocrite
6,464 posts since Oct 2004
Reputation Points: 1,447
Solved Threads: 1,608
Skill Endorsements: 34
Translating too closely doesn't allow you to take adavantage of the chosen language's true power/elegance.
vegaseat
DaniWeb's Hypocrite
6,464 posts since Oct 2004
Reputation Points: 1,447
Solved Threads: 1,608
Skill Endorsements: 34
Question Answered as of 2 Months Ago by
vegaseat As long as you can make the program function the way you want. You learn a lot more that way.
Lardmeister
Posting Virtuoso
1,938 posts since Mar 2007
Reputation Points: 465
Solved Threads: 72
Skill Endorsements: 5