We will be working with the concept of bank accounts in order to explore more object-oriented code as well as a few other new topics.
- This is an individual project.
- Fork this repo to your Github account
- Clone the forked repo into
~/C5/projects:$ git clone [YOUR FORKED REPO URL] - Enter the created directory:
$ cd BankAccounts - Run
git statusto verify the branch you are on - Run
git remote -vto verify the folder you are in corresponds to the fork you have created.
- Create a
Bankmodule which will contain yourAccountclass and any future bank account logic. - Create an
Accountclass which should have the following functionality:
- A new account should be created with an ID and an initial balance
- Should have a
withdrawmethod that accepts a single parameter which represents the amount of money that will be withdrawn. This method should return the updated account balance. - Should have a
depositmethod that accepts a single parameter which represents the amount of money that will be deposited. This method should return the updated account balance. - Should be able to access the current
balanceof an account at any time.
- A new account cannot be created with initial negative balance - this will
raiseanArgumentError(Google this) - The
withdrawmethod does not allow the account to go negative - Willputsa warning message and then return the original un-modified balance
- Create an
Ownerclass which will store information about those who own theAccounts.- This should have info like name and address and any other identifying information that an account owner would have.
- Add an
ownerproperty to each Account to track information about who owns the account.- The
Accountcan be created with anowner, OR you can create a method that will add theownerafter theAccounthas already been created.
- The
- Update the
Accountclass to be able to handle all of these fields from the CSV file used as input.
- For example, manually choose the data from the first line of the CSV file and ensure you can create a new instance of your Account using that data
- Add the following class methods to your existing
Accountclass
self.all- returns a collection ofAccountinstances, representing all of the Accounts described in the CSV. See below for the CSV file specificationsself.find(id)- returns an instance ofAccountwhere the value of the id field in the CSV matches the passed parameter
The data, in order in the CSV, consists of:
- ID - (Fixnum) a unique identifier for that Account
- Balance - (Fixnum) the account balance amount, in cents (i.e., 150 would be $1.50)
- OpenDate - (Datetime) when the account was opened
- Implement the optional requirement from Wave 1
- Add the following class methods to your existing
Ownerclassself.all- returns a collection ofOwnerinstances, representing all of the Owners described in the CSV. See below for the CSV file specificationsself.find(id)- returns an instance ofOwnerwhere the value of the id field in the CSV matches the passed parameter
The data, in order in the CSV, consists of:
- ID - (Fixnum) a unique identifier for that Owner
- Last Name - (String) the owner's last name
- First Name - (String) the owner's first name
- Street Addess - (String) the owner's street address
- City - (String) the owner's city
- State - (String) the owner's state
- Add the instance method
accountsto theOwnerclass. This method should return a collection ofAccountinstances that belong to the specific owner. To create the relationship between the accounts and the owners use anaccount_owners.csvfile. The data for this file, in order in the CSV, consists of:
- Account ID - (Fixnum) a unique identifier corresponding to an
Accountinstance. - Owner ID - (Fixnum) a unique identifier corresponding to an
Ownerinstance.
- Create a
SavingsAccountclass which should inherit behavior from theAccountclass. - It should include the following updated functionality:
- The initial balance cannot be less than $10. If it is, this will
raiseanArgumentError- Updated withdrawal functionality:- Each withdrawal 'transaction' incurs a fee of $2 that is taken out of the balance.
- Does not allow the account to go below the $10 minimum balance - Will output a warning message and return the original un-modified balance
- It should include the following new methods:
-
#add_interest(rate): Calculate the interest on the balance and add the interest to the balance. Return the interest that was calculated and added to the balance (not the updated balance).- The parameter
rateis assumed to be a percentage (i.e. 0.25). - The formula for calculating interest is
balance * rate/100- Example: If the interest rate is 0.25% and the balance is $10,000, then the interest that is returned is $25 and the new balance becomes $10,025.
- The parameter
- Create a
CheckingAccountclass which should inherit behavior from theAccountclass. - It should include the following updated functionality:
- Updated withdrawal functionality:
- Each withdrawal 'transaction' incurs a fee of $1 that is taken out of the balance. Returns the updated account balance.
- Does not allow the account to go negative. Will output a warning message and return the original un-modified balance.
-
#withdraw_using_check(amount): The input amount gets taken out of the account as a result of a check withdrawal. Returns the updated account balance. - Allows the account to go into overdraft up to -$10 but not any lower
- The user is allowed three free check uses in one month, but any subsequent use adds a $2 transaction fee
-
#reset_checks: Resets the number of checks used to zero
- Create a
MoneyMarketAccountclass which should inherit behavior from theAccountclass.- A maximum of 6 transactions (deposits or withdrawals) are allowed per month on this account type
- The initial balance cannot be less than $10,000 - this will
raiseanArgumentError - Updated withdrawal logic:
- If a withdrawal causes the balance to go below $10,000, a fee of $100 is imposed and no more transactions are allowed until the balance is increased using a deposit transaction.
- Each transaction will be counted against the maximum number of transactions
- Updated deposit logic:
- Each transaction will be counted against the maximum number of transactions
- Exception to the above: A deposit performed to reach or exceed the minimum balance of $10,000 is not counted as part of the 6 transactions.
#add_interest(rate): Calculate the interest on the balance and add the interest to the balance. Return the interest that was calculated and added to the balance (not the updated balance).- Note This is the same as the
SavingsAccountinterest.
- Note This is the same as the
#reset_transactions: Resets the number of transactions to zero