7 what is the mistake?


#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
        puts "Withdraw #{amount}. New balance: $#{@balance}."
    else
        puts "pin_error"
    end

def deposit(pin_number, amount)
    if pin_number == pin
       @balance += amount
       puts "Deposit #{amount}. New deposit: $#{@deposit}."
    else
      puts "pin_error"
    end
end 

private 
  def pin
    @pin = 1234
  end
  def pin_error
    return "Access denied: incorrect PIN."
  end
end

 checking_account = Account.new("Eric", 100)
 checking_account.withdraw(11, 500_000)
 checking_account.deposit(1234, 234235)

#2

Did you mean,

    ... New balance: $#{@balance}."