Created
June 27, 2016 14:16
-
-
Save jcotzin/5c8779605b1500daccb17977684e196a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great job! Again, the most important recommendation is that you don't name variables the same as the method. Otherwise, good work!