For my end of the year project, I chose to design and program a virtual ATM machine. The program uses the Account class from Chapter 4, the Lockable interface from Chapter 5, IStream, and the ATM_Machine class, which is the main part of the program. ATM_Machine first stores an array of Account objects. These objects are used to represent different peoples’ bank accounts. Each Account object is passed a person’s name, their account number, their current balance, and their password.
The program then asks for your account number. Because there is no way for me to implement an actual debit card and scanner, you have to type out your account number yourself. For example, type “55554” for the account number when prompted. Next the program checks to see if you inputted a valid account number with the method, boolean isValidAccountNumber(int accountNumber). It is passed in the account number you entered. It then checks through the array of accounts to see if the number you entered matches up with any of the accounts. If it does, the boolean will be true. If not, it will be false and ask you to try again. “55554” is not a valid account number, so now try “55555” so you can move on. The method saves a placeholder for the index of the Account object that you are accessing, so you can use it later in the program.
Next it will ask for your password. For example, type “5554”. The program then will check to see if the password is correct using the method isValidPassword(int password). This method checks to make sure the password entered matches up with the password passed in as the parameter of the Account object. If it is correct, the boolean becomes true and you can pass forward in the program, if incorrect, the boolean will be false and you will have to try again. Now type “5555”, which is the correct password.
Once the correct account number and password combination is entered, the methods in Account will now unlock. Lockable is in place to make sure there is no way you can bypass the code to access an account. You must enter the right account number and password for the methods to unlock so that they are accessible. This would be similar to the security in a real ATM machine, in that you can’t access someone’s account unless they are logged in.
Next you will be prompted to either select check your balance, withdraw, deposit, or quick cash (which is set to automatically withdraw $20). If you select “Check Balance”, it will simply show your current balance. If you select “Withdraw”, you will be prompted to enter how much money you would like to withdraw. If you select “Deposit”, the program will ask how much money you would like to deposit. Finally, if you select “Quick Cash”, it will automatically withdraw $20 from your account. Once you complete your selection, it will print a virtual receipt, then log you out by locking Account.