Queues - Marisol Lopez - BankAccounts#45
Queues - Marisol Lopez - BankAccounts#45marisol-lopez wants to merge 6 commits intoAda-C7:masterfrom
Conversation
Bank AccountWhat We're Looking For
Excellent work overall! |
|
|
||
| module Bank | ||
| class Account | ||
| attr_accessor :id, :balance, :date_created |
There was a problem hiding this comment.
Should these be attr_accessor? Seems to me that attr_reader would be more appropriate - you don't want people trying to modify @balance directly, they should go through withdraw or deposit instead.
| end | ||
|
|
||
| def withdraw(amount) | ||
| if amount < (@balance - 11) |
There was a problem hiding this comment.
Would it be possible to refactor your withdraw methods so that the versions in the subclasses could take advantage of Account.withdraw? You might need to add some extra information about fees or minimum balances, but it has the potential to make the code much DRYer.
It looks like you may have been headed way with the @fee instance variable, but I don't think it ever gets used.
|
|
||
| module Bank | ||
| class CheckingAccount< Account | ||
| attr_accessor :id, :balance |
There was a problem hiding this comment.
Turns out the attr_accessor methods are one of the things we get for free via inheritance, so this line is not needed.
| account = Bank::CheckingAccount.new(1337, start_balance) | ||
| new_balance = start_balance - ((withdrawal_amount * 7) + 4) | ||
|
|
||
| 5.times do |
There was a problem hiding this comment.
I really like the idea of using a times loop here to avoid writing the same code many times. Good work!
Bank Account
Congratulations! You're submitting your assignment.
Comprehension Questions
raise ArgumentError? What do you think it's doing?.all&.findmethods class methods? Why not instance methods?