This post is an attempt at not only getting my previous code running right, but also to clean up some of the ideas that I feel I only implemented half-baked. I’m aliasing this post as “the cleanup”.
It turns out that there were several things I wasn’t understanding properly with project banking.
Click here to take a look at my first attempt…
PS. Have your barf bags prepped and ready, pre-flight. LoL
The first issue was with how I attempted to initialize the @balance instance variable.
I omitted adding balance as a parameter for initialize, which is what was causing the argument error associated with Account#initialize method.
This has now been changed.
It made perfect sense to streamline the Account class. I recreated the #withdraw and #deposit methods, while adding an :amount attribute to be set via the client, and allowed balance to be read.
Here is what the Account class looks like currently.
Next up is the Interact class. I removed the require_relatives at the top of both the Account and Interact classes because they weren’t serving any purpose. And instead of keeping to the previous design (from the interact.rb code snippet in part 1). It made sense for me to simplify this class’ purpose into one larger method, with an understanding that a refactor will be in order in the near future.
Last up is the Banking.rb file, which loads the Interact.rb, and Account.rb files. Finishing off by performing a loop that will will start the bank transaction over and over again. I will add an ability to break out of this loop in another post on this topic. Probably during the refactor.
What I set out to demonstrate over the past two posts was my knowledge of classes being able to interact together.
Thanks to @marksim, for taking time out of his busy schedule to walk me through some basics.
And of course Jk@airpair for providing the medium for me to receive instruction upon such short notice.