Hack Project (ATM) Part II

Hello, Welcome back today I can happily tell you that my ATM program is nearly complete. Today I’d like to share my code, go through the design of my program , and show you some object oriented programming in Hack.

 

Here is a link to my code I have been working on.

Source File of my project

Feel free to download the file and try to run it.

 

This program features 4 classes . They are BankAccount, NewBankAccount, AccountSession, and Bank. AccountSession is a BankAccount that is being used currently it must be authenticated (correct name and pin) in order to instantiate. NewBankAccount is a BankAccount that describes accounts that are new to this bank therefore they (the user ) would input their initial balance as well as name and pin.  BankAccount contians a name , pin , and balance.

The Bank class holds the information  on all BankAccounts through a Vector. A vector in Hack is a collection much like in Java collections and can take types of data that we create and that is what I did here. I created a vector of BankAccount.

 

Hack supports inheritance by using the keyword extends much like in Java. According to the official Hack tutorial there is also support for Interfaces, but I didn’t feel the need to use one for this project.

 

Referencing methods bound by the object is done by objectname->methodname. If the object is not bound or static we reference the syntax is slightly different classname::methodname.

 

Next week I will demonstrate this ATM for you all.

 

 

Leave a comment