Skip to content

Lisa's bank-account.rb#12

Open
Lisa-Sano wants to merge 28 commits intoAda-C5:masterfrom
Lisa-Sano:master
Open

Lisa's bank-account.rb#12
Lisa-Sano wants to merge 28 commits intoAda-C5:masterfrom
Lisa-Sano:master

Conversation

@Lisa-Sano
Copy link

Solo project by Lisa Rolczynski.

Requires 'csv' and 'money' and may also need the following for the 'money' gem to work:
I18n.enforce_available_locales = false

I added two new modules (BankMethod and Interest) to prevent repetitive code!

…and @balance instance variables.  Instantialize and print out id and balance to test.
If trying to withdraw more money in the account, prints an insufficient funds message and does not take any money out of the account.  Tested both methods with an instance of the Account class.
…name, and address. Instantiated an owner object to test out
Owners can be added during instantiation, or later using the add_owner method.
This method instantiates Account objects from a CSV file.  Added creation date to Accounts.
… took out "puts" tests at the end.

Had many places where I converted integers to Money objects, but took those out and created a single method (to_money) that turns balance into a Money object.
self.find class method runs self.all (to create an array of accounts), iterates through and tries to match id to each instance.  if found, returns the account instance.
Altered instance variables in Owner class to match the fields provided in the CSV file.

Changed to_money method in Account class to get_balance.  This method will be called if someone wants to see their balance (returns a formatted Money obj). Removed :balance from the attr_reader since balance will not be accessed this way.
Using the account_owners.csv file, the accounts method can be used to get the account instances that are associated with a particular owner.
…ccount and Owner classes.

Previously, if the find was unsuccessful, the entire account collection was being returned.  Now, if the number is not found, it returns nil.
… and a method in Account (in_balance_enough) to check if the initial balance is valid (not a negative number)
…ngsAccount sublclass (initial balance can't be less than $10)
Updated methods is_balance_enough and withdraw in SavingsAccount subclass.
Withdrawing from a checking account now charges a fee of $1.00.
…hod to CheckingAccount class. No fee for the first 3 checks, then $2 fee for all future checks.
…f in class methods while getting data from CSV files). Where appropriate, use balance instead of @balance (set attr_reader :balance).
Max 6 transactions until reset (no reset method yet). Updated withdraw to include a $100 fee if the balance goes below $10000. No more withdrawals until balance above $10000. Deposits to bring balance above $10000 don't count towards total # transactions.
…l limit and general limit (these values were always the same within a given class).

Made check_fee a local variable since it wasn't applicable for more than the withdrawal_using_check method.
…classes). Added reset_transactions method to MoneyMarketAccount. Changed constant to BALANCE_MINIMUM (more accurate name).
…by self.all to create a collection of new instances from csv files. Previously, two different classes contained their own versions of this method, so now both call this module's method instead.
Now calling this method from the Account and Owner classes instead of repeating the code in each.
…ner class to @id.

if owner has no associated accounts, return nil (instead of tripping error)
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.

1 participant