Skip to Content
Banking on Ruby
Displaying the Balance

Perfect! Now let’s tackle the first public method, display_balance, which we’ll use to display our current account balance.



Define a public display_balance method to your Account class. It should take a single parameter, pin_number.

The body of your method should check whether the pin_number is equal to pin (the result of calling the private pin method)

If it is, display_balance should puts "Balance: $#{@balance}."

Otherwise (else), it should puts pin_error (the pin_error message).

Folder Icon

Take this course for free

Already have an account?