Skip to content
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

Haby Randall Bank Accounts #30

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open

Haby Randall Bank Accounts #30

wants to merge 26 commits into from

Conversation

habypsow
Copy link

Bank Account

Congratulations! You're submitting your assignment.

Comprehension Questions

Question Answer
Why is it useful to put classes inside modules? What do you think? It is useful to place classes inside modules because they are a way of grouping together methods, classes, constants, etc. In this exercise, we were able to utilize the same module for multiple classes and methods.
What is accomplished with raise ArgumentError? What do you think it's doing? The test is ensuring that if something that makes the code not behave in the way that we want it to behave, that an error of the user choice will be placed. It is to ensure that we are getting the behavior we are looking for.
Why do you think we made the .all & .find methods class methods? Why not instance methods? I think the class methods were used because we are looking at the class as a whole in those specific examples, and not at single instances of the class there.
Why does it make sense to use inheritance for the different types of accounts? We were able to adapt specific behaviors desired from the parent class to the subclass, and this way were able to keep our code dry by not repeating code.
Did the presence of automated tests change the way you thought about the problem? How? Yes, I had to think of building a test before writing the code, which I can see will be useful in writing code that is accurate and precise as I improve with this skill.

@CheezItMan
Copy link

Bank Account

What We're Looking For

Feature Feedback
Wave 1
All provided tests pass Yes, once I changed the CSV.read, see the other comment.
Using the appropriate attr_ for instance variables Perfect
Wave 2
All stubbed tests are implemented fully and pass Check
Created instances (by calling new) in Account.all Check
Used CSV library only in Account.all (not in Account.find) Check, well done!
Used Account.all to get account list in Account.find Well done!
Wave 3
All stubbed tests are implemented fully and pass Check
Used inheritance in the initialize for both Checking and Savings Accounts (min balance) Check
Used inheritance for the withdraw in checking and savings accounts You did, although you've got an error in SavingsAccount withdrawal and you have the same error in CheckingAccout. I also noticed you didn't test the CheckingAccount withdraw method.
Baseline
Used Git Regularly Lots of commits over time, nicely done.
Answer comprehension questions Modules: Using modules allows us to namespace our classes so we can avoid naming conflicts. ArgumentError: It allows us to force users of our class to only provide usable data. Inheritance: perfect answer.
Extras
Owner Class Looks like you got started on Owner

Summary

Not bad, a few problems with your inheritance, you could use super in places to DRY your code a bit more. You also had a few bugs handling you withdrawal both in your tests and code. I've put in comments where.

Overall you did a fine job on a hard project. Nice work.

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments in the code, just so you can see where you had small problems.

def self.all
account = []
CSV.open("/Users/habsr/ada/projects/BankAccounts/support/accounts.csv", "r").each do |file|
id = Integer(file[0])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make it so it'll work no matter where you clone the repo this should be:

CSV.open("support/accounts.csv", "r").each do |file|

puts "Warning, this will make your balance below your mininum , the current balance is " + (@balance.to_s)
@balance
else
super + (-2)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be:

super(withdrawal_amount + 2) because you're taking the return value of the Account class' withdraw method and subtracting two from it. You're not changing @balance in the end.

Let me know if this is confusing.

# TODO: Your test code here!
savings_account = Bank::SavingsAccount.new(11, 200)
new_balance = savings_account.withdraw(10)
new_balance.must_equal 188

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you run the test

savings_account.balance.must_equal 188

here, it will fail. It's because the balance isn't getting updated. when you call super in the savings account, you should be passing it the amount + 2 to ensure it adds in the fee. You're only getting the return value from the withdraw method not the balance attribute.

class CheckingAccount < Account
attr_reader :id, :balance
def initialize(id, balance)
@id = id

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super would be swell here!

if check_balance < 0
puts "Warning, this will be below 0 , " + (@balance.to_s)
else
super + (-1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same problem with CheckingAccount earlier.

@balance = balance
@check_num = 3

def withdraw(withdrawal_amount)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any testing for this method...

attr_reader :id, :balance, :interest

def initialize(id, balance)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can probably use super to set the instance variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants