Skip to content

Instantly share code, notes, and snippets.

@jcotzin
Created June 27, 2016 14:16
Show Gist options
  • Save jcotzin/5c8779605b1500daccb17977684e196a to your computer and use it in GitHub Desktop.
Save jcotzin/5c8779605b1500daccb17977684e196a to your computer and use it in GitHub Desktop.
class BankAccount
attr_accessor :balance, :name
@@minimum_balance = 200
@@overdraft_fee = 25
def self.overdraft_fee=(overdraft_fee)
@@overdraft_fee=overdraft_fee
end
def self.minimum_balance=(minimum_balance)
@@minimum_balance=minimum_balance
end
def initialize(balance, name)
if balance < @@minimum_balance
raise(ArgumentError)
else
@balance = balance
@name = name
end
end
def balance
@balance
end
def deposit(deposit)
@balance = @balance + deposit
end
def withdrawl(withdrawl)
@balance = @balance - withdrawl
if withdrawl > @balance
@balance = @balance - @@overdraft_fee
end
end
def transfer(amount, account2)
self.withdrawl(amount)
account2.deposit(amount)
end
end
@jciancio
Copy link

Great job! Again, the most important recommendation is that you don't name variables the same as the method. Otherwise, good work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment