Java Reference
In-Depth Information
Users and customers represent the same concept in this program. Let's use a class
Customer . A customer has two bank accounts, and we will require that a
Customer object should be able to locate these accounts. (Another possible
design would make the Bank class responsible for locating the accounts of a given
customerȌsee Exercise P12.9.)
A customer also has a customer number and a PIN. We can, of course, require that
a customer object give us the customer number and the PIN. But perhap s that isn't
so secure. Instead, simply require that a customer object, when given a customer
number and a PIN, will tell us whether it matches its own information or not.
558
559
A bank contains a collection of customers. When a user walks up to the ATM and
enters a customer number and PIN, it is the job of the bank to find the matching
customer. How can the bank do this? It needs to check for each customer whether
its customer number and PIN match. Thus, it needs to call the match number and
PIN method of the Customer class that we just discovered. Because the find
customer method calls a Customer method, it collaborates with the Customer
class. We record that fact in the right-hand column of the CRC card.
When the simulation starts up, the bank must also be able to read account
information from a file.
Search WWH ::




Custom Search