Sep-16-2020, 05:35 PM
I am trying to work on an ATM project for practice purpose, where its checks for the pin entered and if it is correct then shows options to deposit, check balance or transfer.
I am trying to implement it in one flow i mean if i run a class i should be able to all this by calling each other function inside the class.
In below code im have written the class
I am trying to implement it in one flow i mean if i run a class i should be able to all this by calling each other function inside the class.
In below code im have written the class
Atm ()when i call this class, it asks for the pin and then calls the
main()which calls
pin_checkthen pin_Check calls
optionsHere in my program i am getting this error:
NameError: name 'main' is not definedHow can i make my class's methods see and interact with other method of same class.
class Atm: balance = 10000 def __init__(self): print("PIN should be exactly 4 digit") self.pin1 = input("Please input Your PIN: ") self.pin2 = input("Re-Enter you PIN: ") main() def options(): opt=input("Enter the options from 1-4 \n 1= Check saving balance \n 2= Deposit funds \n 3= Withdraw funds \n 4= Transfer funds \n") def pin_check(self): pin1 = self.pin1 pin2 = self.pin2 if((len(pin1)==4 or len(pin2)==4) and (pin1==pin2)): print('Pin OK') a=options() return a else: print('\n\n !!!!ALERT-INVALID PIN!!!!\n\n !! PIN SHOULD MATCH !! \n\n & \n \n PIN SHOULD BE 4 DIGITS\n !!NO CHARS ALLOWED!!') def main(self): a=pin_check(self) return a a=Atm() a