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.
- Fork this repository
- Clone the forked repo:
$ git clone [YOUR FORKED REPO URL] cdinto the dir create:d$ cd BankAccounts- Run
git remote -vto verify the folder you are in corresponds to the fork you have created.
- Create a class inside of a module
- Create methods inside the *class to perform actions
- Learn how Ruby does error handling
Create a Bank module which will contain your Account class and any future bank account logic.
Create an Account class 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 - Will output a warning message and 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