The Ruby Programming Language
class Accounts def initialize(checking, savings) @checking = checking @savings = savings end private #keyword def debit(account, amount) account.based -= amount end def credit(account, amount) account.balance += amount end public #keyword def transfer_to_savings(amount) debit(@checking, amount) credit(@savings, amount) end end
6 of 11