Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Account
- attr_reader :name
- attr_reader :balance
- def initialize (name, balance = 100)
- @name = name
- @balance = balance
- end
- private
- def pin (pin = 1234)
- @pin = pin
- end
- private
- def pin_error
- return "Access denied: incorrect PIN."
- end
- public
- def display_balance(pin_number)
- pin_number == pin ? puts "Balance: $#{@balance}." : pin_error
- end
- public
- def withdraw(pin_number, amount)
- pin_number == pin ? (@balance -= amount) : (pin_error)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment