Error - "did you create a variable called checking_account?"


#1



https://www.codecademy.com/en/courses/ruby-beginner-en-32cN3/0/6?curriculum_id=5059f8619189a5000201fbcb


I have looked over this code countless times and cant see where I'm going wrong? Why am I always getting the error

"did you create a variable called checking_account?"

The variable looks ok to me? So perhaps I've made an error elsewhere?

Thanks

class Account
    attr_reader :name
    attr_reader :balance
    
def initialize (name, balance=100)
    @name = name
    @balance = balance
    end
    
private 

def pin
    @pin = 1234
    end

private

def pin_error
    "Access denied: incorrect PIN."
    end

public 
   
def display_balance (pin_number)
    if pin_number == pin
    puts "Balance: $#{@balance}."
    else 
    puts pin_error
end

public

def withdraw (pin_number, amount)
    if pin number == pin
        @balance -= amount
        puts "Withdrew #{amount}. New balance: $#{@balance}."
    else
    puts pin_error
    end
end

checking_account = Account.new ("Lawrence",500)


#2

I'm guessing that the interpreter is giving you an error message, you'll need to sort that out.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.