Advertisement
Guest User

Untitled

a guest
Jun 26th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. class BankAccount
  2. attr_accessor :balance
  3.  
  4. @@minimum_balance = 200
  5.  
  6. def self.minimum_balance=(balance)
  7. @@minimum_balance = balance
  8. end
  9.  
  10. def initialize(balance,name)
  11. if balance < @@minimum_balance
  12. raise ArgumentError.new("Error")
  13. else
  14. @balance = balance
  15. @name = name
  16. end
  17. end
  18.  
  19. def deposit(deposit)
  20. @deposit = deposit
  21. @balance += @deposit
  22. end
  23.  
  24. def withdraw(withdraw)
  25. @withdraw = withdraw
  26. @balance -= @withdraw
  27. end
  28.  
  29. def transfer(transfer, account2)
  30. self.balance -= transfer
  31. account2.balance += transfer
  32. end
  33.  
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement