CSC 175 Intermediate Programming
Spring 2024
Project Assignment


  • This project builds upon previous lab exercises and examples of Dialog Boxes and File I/O.

  • This project builds upon labs 11, 12, 14, 15, 17 (if you did the Bank option of this exercise), 18, 20, and an upcoming lab (recursive method: binary search). The data of the ADT Bank must include a collection of accounts (which is an array or ArrayList, depending on whether your main/driver class ATM calls the constructor of Bank from lab 12 or Bank2 from lab 18, respectively). You may reuse and update the bank related classes you implemented for labs. Make sure, as in lab 11, your Account class has a compareTo(Account acc) method for comparing two Account objects, based on their account numbers. For the ADT Bank, include operations for adding a new account (account numbers must be unique; no duplicates allowed), sorting (you may use one of the following: quicksort, mergesort, selection sort, or insertion sort; see SortsClass.java ), searching for the account information (name and balance) associated with a given account number (have your search method call binarySearch -- an upcoming lab), depositing an amount to a given account, and withdrawing an amount from a given account; when implementing these operations, reuse when possible the methods of the Account class.

  • Design and implement a bank ATM driver class with methods for each of the following (use additional helper classes and methods as needed):
    1. Read account information into a Bank object from a file: in_accounts.txt . Each line of the input file has info for one account, i.e. id, name, balance. (This is Lab 20 exercise 1.)
    2. Ask the user to login by entering id, using a dialog box or standard input. (This is Lab 20 exercise 2.)
    3. Validate id. (This is Lab 20 exercise 3.)
    4. Ask the user to enter a transaction (check balance / deposit / withdraw) using a dialog box or standard input.
    5. Validate the transaction.
    6. Execute the transaction.
    7. When the user is done, write all account information (one line per account) in sorted ascending order of account ids, to an output file out_accounts.txt (see example of writing text to a file (which uses predefined classes in the java.io package: PrintWriter and FileWriter, so import java.io.PrintWriter; import java.io.FileWriter;), taken from examples of Dialog Boxes and File I/O).

  • "Validate" means check that the user input is valid (depending on how you read it in). Take appropriate action in the case of the user entering invalid data (e.g. displaying a message to the user and allowing the user to try again) rather than crashing or using the invalid data in subsequent operations.
  • Your application should not crash upon an exception being thrown; rather it should be caught and handled appropriately (e.g. no change to the account and a message to the user).

  • Once you have the above working, incorporate overdraft protection by introducing a subclass of Account called Checking (previous lab exercise), which has an instance variable overdraftMaximum and overrides the withdraw method of Account so that it checks whether the amount to be withdrawn exceeds the balance by more than overdraftMaximum; if so, it throws an exception: InsufficientFundsException; otherwise, it performs the withdrawal.
    • For example, if the balance is 100.00, and the account is a regular checking account (no overdraft protection), then the account holder can withdraw up to 100.00; if the balance is 100.00, and the account has overdraft protection with an overdraft maximum of 50.00, then the account holder can withdraw up to 150.00. Each line of the input file now looks like this: id, name, balance, account type (r = regular, c = checking), and overdraft maximum (if account type is checking).
    Note: your application should not crash upon an InsufficientFundsException being thrown; rather it should be caught and handled appropriately (i.e. no change to the account and a message to the user). If you did not do the lab exercise on InsufficientFundsException because you did the corresponding exercise for the game Explore, that is ok -- just hand in that exercise too.



What to submit:

For any program that you implement, hand in your source code (create a zipped/jar file containing all .java files of your project folder) as well as the output of your test cases. For this assignment, include input and output files, along with a README file that explains how to use the application; include your JUnit classes that test Bank (storing accounts in an array), Bank2 (storing accounts in an ArrayList), Account, Checking and Money. You do not need a JUnit test class for the ATM class; instead, for the ATM class, include screen snapshots and/or a test plan that shows what tests you performed, and the results when you executed your ATM's main method.

Also, please complete and submit this self-reflection template; this is a required part of the project.

Correctness counts for 50% of your grade. Test cases (which should include both "normal" and "special" cases) count for 25% of the grade. Readability counts for 25%. Your program should be modular. Choose appropriate names for your identifiers. Use comments (Javadoc style), preconditions, postconditions and indentation appropriately. Follow the programming conventions/guidelines we discussed.