Could anyone explain exercise num 7


#1

1_how to get out a private method out of it's class?
2_what's the meaning of"error checking" ?


#2

I think that is a rhetorical question on the part of the author. We cannot get the PIN out unless we write a method to get it.

The second question refers to checking entries and amounts for correctness. Take for instance,

  def over_error
      "Attempting to withdraw more than allowed balance"
  end

Can be added under pin_error, and the withdraw method tweaked:

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

#3

Thanks for this, I had completely overcomplicated this withdraw tweak and was getting nowhere!


#4