I’ve been all over google and stack over flow and I can’t seem to find the answer.
I need the “bookman” function to find the instance of ‘cash’ so that it can call cash’s methods.
How can I accomplish this?
Thanks!
Here is my code
class Account
def initialize (deb_bal, cred_bal)
@deb_bal = deb_bal
@cred_bal = cred_bal
end
def debit(x)
@deb_bal += x
end
def credit(x)
@cred_bal += x
end
def balance
bal = @deb_bal.to_i - @cred_bal.to_i
if bal < 0
puts "Credit Balance of #{bal.abs}"
else
puts "Debit Balance of #{bal.abs}"
end
end
end
def bookman
end
cash = Account.new(0,0)
#acts_rec = Account.new
cash.credit 100
bookman
You could pass the object into the method: