CS 3291 (Java with Internet Applications):
Homework #2

Assigned:
September 10, 1999.

Due:
September 24, 1999, class time.

Credit:
20 points.

Objective:
Write a program that defines and uses a variety of classes.

General description:
You are to write a program that simulates some of the operation of a bank. For this program, you can regard a bank as a collection of accounts. For each account, the bank records an account number (integer), a PIN (integer), a name (string), a balance (integer), and a transaction history (more about that shortly). This bank is a closed system in that money can be transferred from one account to another, but not to or from the outside world. We want to record the following types of transactions: Since we have not yet discussed Java's GUI features, the program will have a simple CLI, described below. You will have access to an Input class that provides relatively easy-to-use methods for reading from files and standard output, and you already know how to write to standard output.

Instructions:
  1. Read about the Input class in Helpful hints section below and look at the sample programs.
  2. Read the detailed description of the bank program in the Detailed description section below.
  3. Decide what classes (in addition to a Bank class) you want to define.
  4. Implement the classes you decide on, and then use them to write a program that behaves as described below. You should end up with a Bank class whose main method behaves as described, and probably some other classes as well. To simplify the grading process, aim to have a single source file called Bank.java. See the Helpful hints section below if you're confused about how to do this.
  5. Test the program until you are satisfied that it works.
  6. Submit your Java source file, as described in How to submit homework.

Helpful hints:
  1. You can use the Input class, defined in Input.java, to do input from a file or from standard input (the terminal, unless redirected). This class, written by a professor at University of Florida for her introductory course, provides some pretty easy-to-use methods for reading numbers and strings from either standard input or a file. See the main method in the Input class, or example programs TestInput.java, TestFileInput.java, and TestInputLoop.java, for examples of using these methods. To make use of this class, copy the source into the directory in which you will be working and compile it. You can assume that when we test your program, we will supply a copy of Input.class, so you do not need to copy code from Input.java into your source.
  2. You may find some of Java's core classes -- the ones we've discussed in class so far -- helpful. (If you have not already done so, read about the Vector and Hashtable classes in chapter 9.)
  3. You may also find the partial example from February 5's class helpful as an example of (1) object-oriented design for a somewhat similar problem and (2) defining and using more than one class in a single source file. See AddrBook.java.

Detailed description:

Grading:
This homework is worth 20 points: