# Class methods are defined with a decorator @classmethod. They belong to the class itself instead of the instance. Instead of implicitly passing self into the method, we pass cls. This is reference to the class.
# Static methods are functions defined within the class with a decorator @staticmethod.  They have no access on instance or class attributes so we do need to pass any arguments into them.

class BankAccount:
    # class attribute
    bank_name = "First National Dojo"
    all_accounts = []
    def __init__(self, int_rate,balance):
        self.int_rate = int_rate
        self.balance = balance
        BankAccount.all_accounts.append(self)

    def with_draw(self,amount):
        # we can use the static method here to evaluate
        # if we can with draw the funds without going negative
        if BankAccount.can_withdraw(self.balance,amount):
            self.balance -= amount
        else:
            print("Insufficient Funds")
            return self
    # static methods have no access to any attribute
    # only to what is passed into it
    @staticmethod
    def can_withdraw(balance,amount):
        if (balance - amount) < 0:
            return False
        else:
            return True

    # class method to change the name of the bank
    @classmethod
    def change_bank_name(cls,name):
        cls.bank_name = name
    # class method to get balance of all accounts
    @classmethod
    def all_balances(cls):
        sum = 0
        # we use cls to refer to the class
        for account in cls.all_accounts:
            sum += account.balance
        return sum
print(BankAccount.all_balances())

62498844f765d303421b77a320d9772cf5a067c5
class BankAccount:
    <mask token>
    <mask token>

    def __init__(self, int_rate, balance):
        self.int_rate = int_rate
        self.balance = balance
        BankAccount.all_accounts.append(self)
    <mask token>

    @staticmethod
    def can_withdraw(balance, amount):
        if balance - amount < 0:
            return False
        else:
            return True
    <mask token>
    <mask token>


<mask token>

class BankAccount:
    <mask token>
    <mask token>

    def __init__(self, int_rate, balance):
        self.int_rate = int_rate
        self.balance = balance
        BankAccount.all_accounts.append(self)

    def with_draw(self, amount):
        if BankAccount.can_withdraw(self.balance, amount):
            self.balance -= amount
        else:
            print('Insufficient Funds')
            return self

    @staticmethod
    def can_withdraw(balance, amount):
        if balance - amount < 0:
            return False
        else:
            return True

    @classmethod
    def change_bank_name(cls, name):
        cls.bank_name = name

    @classmethod
    def all_balances(cls):
        sum = 0
        for account in cls.all_accounts:
            sum += account.balance
        return sum


<mask token>

class BankAccount:
    bank_name = 'First National Dojo'
    all_accounts = []

    def __init__(self, int_rate, balance):
        self.int_rate = int_rate
        self.balance = balance
        BankAccount.all_accounts.append(self)

    def with_draw(self, amount):
        if BankAccount.can_withdraw(self.balance, amount):
            self.balance -= amount
        else:
            print('Insufficient Funds')
            return self

    @staticmethod
    def can_withdraw(balance, amount):
        if balance - amount < 0:
            return False
        else:
            return True

    @classmethod
    def change_bank_name(cls, name):
        cls.bank_name = name

    @classmethod
    def all_balances(cls):
        sum = 0
        for account in cls.all_accounts:
            sum += account.balance
        return sum


<mask token>

class BankAccount:
    bank_name = 'First National Dojo'
    all_accounts = []

    def __init__(self, int_rate, balance):
        self.int_rate = int_rate
        self.balance = balance
        BankAccount.all_accounts.append(self)

    def with_draw(self, amount):
        if BankAccount.can_withdraw(self.balance, amount):
            self.balance -= amount
        else:
            print('Insufficient Funds')
            return self

    @staticmethod
    def can_withdraw(balance, amount):
        if balance - amount < 0:
            return False
        else:
            return True

    @classmethod
    def change_bank_name(cls, name):
        cls.bank_name = name

    @classmethod
    def all_balances(cls):
        sum = 0
        for account in cls.all_accounts:
            sum += account.balance
        return sum


print(BankAccount.all_balances())

# Class methods are defined with a decorator @classmethod. They belong to the class itself instead of the instance. Instead of implicitly passing self into the method, we pass cls. This is reference to the class.
# Static methods are functions defined within the class with a decorator @staticmethod.  They have no access on instance or class attributes so we do need to pass any arguments into them.

class BankAccount:
    # class attribute
    bank_name = "First National Dojo"
    all_accounts = []
    def __init__(self, int_rate,balance):
        self.int_rate = int_rate
        self.balance = balance
        BankAccount.all_accounts.append(self)

    def with_draw(self,amount):
        # we can use the static method here to evaluate
        # if we can with draw the funds without going negative
        if BankAccount.can_withdraw(self.balance,amount):
            self.balance -= amount
        else:
            print("Insufficient Funds")
            return self
    # static methods have no access to any attribute
    # only to what is passed into it
    @staticmethod
    def can_withdraw(balance,amount):
        if (balance - amount) < 0:
            return False
        else:
            return True

    # class method to change the name of the bank
    @classmethod
    def change_bank_name(cls,name):
        cls.bank_name = name
    # class method to get balance of all accounts
    @classmethod
    def all_balances(cls):
        sum = 0
        # we use cls to refer to the class
        for account in cls.all_accounts:
            sum += account.balance
        return sum
print(BankAccount.all_balances())
