Superclass mismatch for class SavingsAccount


#1

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

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

def withdraw(pin_number, amount)
    if pin_number == pin && (@balance - amount) >= 0
        @balance -= amount
        puts "Withdrew #{amount}. New balance: $#{@balance}."
    elsif 
    pin_number == pin && (@balance - amount) < 0
    puts "Operation denied, because overdraft"
    else
        puts pin_error
    end
end
def deposit(pin_number, amount)
    if pin_number == pin
        @balance += amount
        puts "Deposited #{amount}. New balance: $#{@balance}."
    else 
        puts pin_error
    end
end

private
def pin
    @pin = 1234
end

def pin_error
  "Access denied: incorrect PIN."
end

end

class SavingsAccount < Account
end

me = SavingsAccount.new("Bob", 500000)
me.withdraw(1234, 99999)

What 's wrong in this way of inheritance?


#2

just missed
attr_reader :name, :balance ))))