-
Notifications
You must be signed in to change notification settings - Fork 39
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
Queues BankAccount Laura #41
base: master
Are you sure you want to change the base?
Conversation
Bank AccountWhat We're Looking For
This is pretty good, and you seem to understand the core concepts well enough, but there are several places where the details don't quite match what we wanted. Please take some time to go through the inline comments, and feel free to reach out to Jamie or I if you have any questions or want to work through something. |
end | ||
|
||
def self.find(id1) | ||
@accounts_array.each do |line| |
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 like the idea of using the accounts loaded in Account.all
here in find
. But there's a problem - if find
is run before all
, you get an error! How could you guarantee that all
has been run by the time you get here?
end | ||
|
||
def self.all | ||
@accounts_array = [] |
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.
You probably want a class variable (two @
s) here. What you'v got is an instance variable defined at the class level, which can act a little weird in some situations. Better to just stick with the class variable, at least for now.
end | ||
|
||
it "Can find the first account from the CSV" do | ||
# TODO: Your test code here! | ||
Bank::Account.all[0].id.must_equal 1212 | ||
end |
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.
Since this test is under describe "Account.find"
, it ought to be using the find
method. How might you modify it to test what it says it tests?
@checks = 0 | ||
end | ||
|
||
def withdraw(withdraw_amount) |
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.
It might be cleaner to use super
here to call Account#withdraw
, and centralize your logic all in one place. In this case Account#withdraw
would probably require more parameters, like a fee and a minimum balance.
# TODO: Your test code here! | ||
end | ||
|
||
it "Doesn't modify the balance if the account would go below -$10" 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.
It looks like you removed a test here, possibly by accident?
balance = 100 | ||
amount = 10 | ||
account = Bank::CheckingAccount.new(17682, balance) | ||
3.times {balance = balance - amount} |
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 like that you used times
here to DRY up this code. Good work!
Bank Account
Congratulations! You're submitting your assignment.
Comprehension Questions
raise ArgumentError
? What do you think it's doing?.all
&.find
methods class methods? Why not instance methods?