- 
                Notifications
    You must be signed in to change notification settings 
- Fork 38
Queues - Marisol Lopez - BankAccounts #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?