For this project, your goal is to write a simple bank imitation program that users can interact with.
You will write three classes: BankAccount, Bank, and BankMenu.
Fields
firstName -- First Name
lastName -- Last Name
address -- Address
balance -- Account Balance (in whole dollars)
userName -- Account Username (unique)
pin -- PIN (used as a password)
Methods
Getters
getFirstName()
getLastName()
getAddress()
getBalance()
getUserName()
getPIN()
Setters
setFirstName(firsName)
setLastName(lastName)
setAddress(address)
setUserName(username)
setPIN(pin)
Other
addBalance(amount)
subtractBalance(amount)
isValidName(name) -- check whether the first (or last) name is valid
isValidUserName(userName) -- check whether a username is valid
isValidPIN(pin) -- check whether a pin is valid
Fields
accounts -- array of BankAccount objects
name -- Name of the bank
numAccounts -- number of bank accounts in the accounts array
Methods
getAccount(userName, pin) -- return a BankAccount identified by the name userName (if found and confirmed with PIN). Return null otherwise (and print appropriate error messages).
registerAccount(account) -- add a bank account. Make sure the username is not a duplicate. Validate fields where appropriate.
terminateAccount(userName, pin) -- terminate (remove) a bank account. Print an error message if the username doesn't exist or the PIN is incorrect.
accountExists(userName) -- return true if the account with the specified user name exists; return false otherwise.
grow() -- internal function that will extend the capacity of the accounts array.
All of the methods in the BankMenu class should be static.
Methods
landingMenu(bank)
This method should show this menu:
1. Log in
2. Sign up
3. Terminate account
4. Exit
loginMenu(bank)
This method should prompt the user for their username and PIN. It should enter the main menu if the entered information is correct, and it should return to login menu otherwise.
signupMenu(bank)
This method should prompt the user to enter all of the necessary details to register a new account. For the username, the method should search the bank to make sure that such username hasn't already been registered.
terminateAccountMenu(bank)
This method shoud prompt the user to enter account username and PIN. A final confirmation dialog ("Are you sure you want to terminate your account? [Y/N]") should be printed before terminating (removing) the account.
mainMenu(account)
This method should greet the user ("Welcome, ...!") and then print this menu:
1. Deposit Money
2. Withdraw Money
3. Account Details
4. Exit
depositMenu(account)
This method should prompt the user to enter the amount of money to deposit and add the entered amount appropriately. Only positive numbers should be allowed.
withdrawMenu(account)
This method should prompt the user to enter the amount of money to withdraw and withdraw the entered amount appropriately. Only positive numbers should be allowed. Quite obviously, the user should not be allowed to withdraw more money than they currently have in their account.
accountMenu(account)
This method should print all of the account details and then show the user the following menu:
1. Change First Name
2. Change Last Name
3. Change Address
4. Change Username
5. Change PIN
6. Exit
changeFirstNameMenu(account)
Prompt the user to enter their PIN again and then print a prompt that asks the user for their new First Name. Validate the name using the isValidName method from the BankAccount class.
changeLastNameMenu(account)
Same as changeFirstNameMenu, except that the information to change is the Last Name.
changeAddressMenu(account)
Same as changeFirstNameMenu, except that the information to change is the Address.
changeUsernameMenu(account)
Same as changeFirstNameMenu, except that the information to change is the Username.
changePINMenu(account)
Same as changeFirstNameMenu, except that the information to change is the PIN.
promptPIN(account)
Prompt the user for their PIN and return true if the entered PIN matches the account. Return false otherwise.