Java代写:CIS304-Bank-Account-Application

What to turn in

Use Export Project in NetBeans to export your project to a zip file, name it YourLastName_FirstName_project.zip. Send the file as a single attachment through Blackboard. The subject of this email is YourLastName_FirstName_project.

Note

Write your name as a comment line at the very beginning of each .java program: 1 point deducted for each file without your name at top.

Besides this documentation, I also provide you a text file, accounts.txt (described below). You should download this text file into the directory of your Netbeans project for your programs. Make sure when accessing this text file programmatically, your program just uses the file name without explicitly providing a path (so called relative path). For instance,

1
File accountFile = new File("accounts.txt");

For more information about the absolute path, refer to chapter 18 lecture slides. Failing to use the relative path loses 4 points.

Suggestions

  1. Start early and start from simple – this is VERY important. For example, begin from the week when the project is available. As the first step, you construct the GUI but not implement functions for button clicks.
  2. For the give function buttons, you may start to implement the Exit function first, and then the functions of Deposit and Withdraw buttons.
  3. Always keep a copy of your working code before you implement more requirements.

Requirements in details

GUI in general

Once the program starts, it reads all account information from accounts.txt (each row in the file is a account record and is in the format of

1
accountNumber<>openDate<>customerName<>balance

The openDate is in the format of year/month/day.) It then fills a JComboBox with all account numbers and shows other GUI controls as in Fig. 1. Your program must be able to “read” the file of this format programmatically because when I test your project, the file content (not the format) will be changed.

When you select an item (account number) from the JComboBox, the corresponding values for openDate, customerName, and balance will be shown in the three read-only text fields, and the Deposit, Withdraw, and Transfer To buttons become enabled, see Fig. 2.

Exit

Clicking this button to close the frame and exit the program.

Instead of using mouse to click the button, pressing Alt + x will also trigger the Exit button.

Deposit

(After selecting an account number from the JComboBox), clicking the Deposit button will popup a window as shown in Fig. 3 asking you to enter a deposit amount for the selected account. Hint: this dialog window is generated by JOptionPane.showInputDialog().

If you enter a non-negative number, such as 100, the amount will be deposited to the account. See Fig 4 - the balanced is adjusted accordingly. The accounts.txt file should also be updated accordingly as well.

If you clicking Cancel in Fig. 3, nothing will happen to this account.

If an invalid deposit amount is entered in Fig. 3, such as -100 or $100, you will see an error message as shown in Fig 5.

Withdraw

(After selecting an account from the JComboBox), clicking the Withdraw button will popup a window as shown in Fig. 6 asking you to enter a withdrawal amount for the selected account.

If you enter a non-negative number, such as 100, and if the account balance is sufficient, the withdrawal will be made from the account successfully. See Fig. 7, the balanced is adjusted. The accounts.txt file should also be updated accordingly as well.

If you clicking Cancel in Fig. 6, nothing will occur to this account.

If an invalid withdrawal amount is entered in Fig. 6, such as -100 or $100, you will see an error message as shown in Fig 8.

If a withdrawal amount is greater than the balance, you show an error message and stop the withdrawal.

Transfer To

(After selecting an account from the JComboBox), clicking the Transfer To button will popup a window as shown in Fig. 10 asking you to enter a beneficiary account number.

If a valid account number (any number existing in the JComboBox) is entered, after click OK button, a window like Fig. 11 pops up asking for amount to transfer.

If a valid amount is entered, and the balance is not less than this amount and sometimes the sum of this transfer amount and a transfer fee, the transfer will be succeeded as shown in Fig. 12 and 13. The transfer fee is only applied to account with the balance less than $10000 which is specified in AccountConstants interface (more about AccountConstants see end of this document).

If an invalid beneficiary account number (i.e., a number which does not exist in the account number JComboBox) is entered in Fig. 10, Fig. 14 shows the error message.

If the balance is not sufficient for the transfer amount, Fig. 15 shows the error message.

If the balance is not sufficient to cover both transfer amount and transfer fee (when such a fee applies), Fig. 16 shows the error message.