There has been a catastrophic system crash in the data warehouse for the bank where you are employed. The servers which maintained the current account balance information of our customers has experienced unrecoverable errors. Luckily the transaction data (deposits and withdrawals) are stored separately and remain intact.
You are tasked with writing a program to read in data files containing this transaction information of all our customers and reporting the current balances of each account of each customer.
The Customer class is provided but needs to be modified. Since it will be used later as a key type, it must override the hashCode() and equals() methods.
Different customers could have the same name and while extremely unlikely, they could also have the same birthday. But it is unlikely that two different customers will have the same name, birthday, and year they first became a customer. This class will use all three to uniquely identify a customer.
Two instances of Customer are considered equal if:
The hashCode() method should return the same value for any two Customers that are equal.
A customer may hold different types of accounts at this bank. The AccountType class defines the types of accounts that the bank services (This enumeration is provided should not be modified in any way):
Each customer may hold up to one account of each type. The AccountBalances class maintains the running balances of each type of account for a single customer. The AccountBalances class should be flexible so that changes are not required if additional account types are added to the AccountType Enumeration in the future.
To enable this flexibility, use a Map with:
The map should be initially empty for new instances of AccountBalances. As transactions are processed (see CustomerDataRestore section below), accounts will be added to this map and the balance values updated by calls to this class.
The CustomerDataRestorer class is the program that will read a transaction log file to recover the current account balance information for all of our customers and print some useful information.
Management has identified a set of immediate data requirements to recover from the transaction log right away. They have specified these requirements by sketching out a main method that calls a sequence of methods to be implemented (see below).
The developer of the application which generates the transaction logs has provided a sample of the data (SampleAccountLog.txt) for you to work with as well as some helper methods for parsing lines of log data.
Implement the following methods in CustomerDataRestorer to complete the program:
public void restoreFromTransactions(File file) throws IOException
For each line of the input file, this method:
public void printAllBalances()
public int getNumCustomers()
public int getNumAccounts()
public int countRepaidLoans()
public Collection
The program output when run on SampleAccountLog.txt should appear as:
Rashida Straw (DOB: Wed Feb 25 00:00:00 EST 1959, Customer since: 2012)
Checking=180.0
Savings=50.0
Loan=-1000.0
Brittany Goodson (DOB: Fri Mar 24 00:00:00 EST 1961, Customer since: 2011)
Checking=20.0
Irish Eaker (DOB: Mon Jun 11 00:00:00 EDT 1979, Customer since: 2009)
Savings=200.0
Loan=0.0
Rashida Straw (DOB: Sun Jan 01 00:00:00 EST 1989, Customer since: 2012)
Checking=100.0
Brittany Goodson (DOB: Fri Mar 24 00:00:00 EST 1961, Customer since: 1999)
Loan=-300.0
Number of customers restored: 5
Number of accounts across all customers: 8
Number of loans repaid:1
Customers that require loan statements sent:
Rashida Straw (DOB: Wed Feb 25 00:00:00 EST 1959, Customer since: 2012)
Brittany Goodson (DOB: Fri Mar 24 00:00:00 EST 1961, Customer since: 1999)
The program output when run on FullAccountLog.txt should appear as (not all lines shown):
Rashida Straw (DOB: Wed Feb 25 00:00:00 EST 1959, Customer since: 2012)
Checking=180.0
Savings=50.0
Loan=-1000.0
…
Ernestina Kinlaw (DOB: Tue Jan 15 00:00:00 EST 1946, Customer since: 2004)
Checking=120.0
Savings=446.0
Loan=271.0
Number of customers restored: 108
Number of accounts across all customers: 300
Number of loans repaid:14
Customers that require loan statements sent:
Rashida Straw (DOB: Wed Feb 25 00:00:00 EST 1959, Customer since: 2012)
Brittany Goodson (DOB: Fri Mar 24 00:00:00 EST 1961, Customer since: 1999)
…
Abigail Suazo (DOB: Wed Aug 15 00:00:00 EDT 1979, Customer since: 2007)
Yoshie Cavin (DOB: Tue Jul 04 00:00:00 EDT 1961, Customer since: 2012)