Did I do the inheritance part right?


#1


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

Create CheckingAccounts or SavingsAccounts that inherit from Account was the directions. Did I do it right? Can you check my code?


class Account
    attr_reader :name
    attr_reader :balance
    
    
    def initialize (name, balance=100)
        @name = name
        @balance = balance
    end
    def display_balance (pin_number)
          if pin_number == pin
              puts "Balance: $#{@balance}."
    
          else
              puts pin_error
          end
    end
    def withdraw(pin_number, amount)
        if pin_number = pin
          if amount > balance
              puts "you cannot withdraw the amount"
          else amount <= balance
            balance=balance - amount
            puts "Withdrew #{amount}.  New balance: $#{@balance}."                end
        else 
            puts pin_error
        end
      
    end
    def deposit (pin_number, amount)
        if pin_number = pin
            balance = 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 Checking_Account < Account
end
checking_account = Account.new("cruise", 900)


#2

This might work but grill your code thoroughly.