Python Forum
cant able to make methods interact with each other in the class
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
cant able to make methods interact with each other in the class
#1
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
Atm ()
when i call this class, it asks for the pin and then calls the
main()
which calls
pin_check
then pin_Check calls
options
Here in my program i am getting this error:
NameError: name 'main' is not defined
How 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  
Reply


Messages In This Thread
cant able to make methods interact with each other in the class - by jagasrik - Sep-16-2020, 05:35 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Class test : good way to split methods into several files paul18fr 4 472 Jan-30-2024, 11:46 AM
Last Post: Pedroski55
  Structuring a large class: privite vs public methods 6hearts 3 1,050 May-05-2023, 10:06 AM
Last Post: Gribouillis
  access share attributed among several class methods drSlump 0 1,058 Nov-18-2021, 03:02 PM
Last Post: drSlump
  a function common to methods of a class Skaperen 7 2,577 Oct-04-2021, 07:07 PM
Last Post: Skaperen
  Listing All Methods Of Associated With A Class JoeDainton123 3 2,339 May-10-2021, 01:46 AM
Last Post: deanhystad
  too many methods in class - redesign idea? Phaze90 3 2,491 Mar-05-2021, 09:01 PM
Last Post: deanhystad
  Special Methods in Class Nikhil 3 2,272 Mar-04-2021, 06:25 PM
Last Post: Nikhil
  Question about naming variables in class methods sShadowSerpent 1 2,002 Mar-25-2020, 04:51 PM
Last Post: ndc85430
  Interact with Python Mario456 1 1,649 Jan-31-2020, 07:14 PM
Last Post: Larz60+
  a class calling one of its own methods? Skaperen 1 1,835 Jul-21-2019, 04:43 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020