I have this text file with customer, account and transaction information in. Each item appears in the order just mentioned line by line.
Dr
James
M
Magee
12/05/1978
12
Dakedon Avenue
Mutley
Plymouth
Devon
PL87TS
babiesrus123
2
54-25-36
2455871265
jennies uni account !!!
02/12/1999
-25.36
2000
8
02/02/2010
OTR
Scottish Highlands Vacations Inc.
-650
-675.36
02/02/2010
C/R
Mobiles Inc - month 4 cash back
20
-655.36
05/02/2010
OTR
C.Oldgam Travel Insurance service
-44.55
-699.91
08/02/2010
POS
Wrapping Up.Net
-800
-1499.91
12/02/2010
OTR
Carphone Warehome
-145
-1644.91
17/02/2010
D/D
Leather World - loan repayment
-75
-1719.91
22/02/2010
D/D
park deans - loan repayment
-88.56
-1808.47
02/03/2010
ATM
Stirling University
-120
-1928.47
58-69-71
12455871265
johns uni account !!!
02/12/1999
-25.36
1500
6
02/02/2010
D/D
SUBar Monthly Bill- Plymouth
-259.99
-285.35
02/02/2010
C/R
Monthly allowance
450
164.65
02/02/2010
D/D
SUBar Monthly Bill- Plymouth
-325.36
-160.71
02/02/2010
C/R
Monthly allowance
450
289.29
02/02/2010
D/D
SUBar Monthly Bill- Plymouth
-78.36
210.93
02/02/2010
C/R
Monthly allowance
450
660.93
In the above snippet from the file is:
1 Customer
2 Accounts
Each Account has several Transactions.
How would i read this information into a Single? ArrayList Data Structure whilst using get and set methods in classes(Customer, Account, Transaction). Whats confusing me is how would i read in this data and keep track of how many accounts a customer has and how many transactions an account has.
From what i think needs doing is a big nested loop to read the information from the text file and keep track of how much information each item has.
Loop through Customer 1
Loop through Customer Account 1
Loop through Customer Account 1 Transactions
Loop through Customer Account 2
Loop through Customer Account 2 Transactions
Loop through Customer 2
...
About the text file:
• Customer ID number --- this is the first customer 1
• Customer title
• Customer first name
• Customer initials //not required - defaults to null
• Customer surname
• Customer date of birth
• Customer house name or number
• Customer street name
• Customer address area //not required - defaults to null
• Customer city or town name
• Customer county
• Customer postcode
• Customer password *minimum size is 8 characters in length
• The number of accounts belonging to this customer --- equals 2 in this example
o Account sort code --- this is the first account of customer 1
o Account Number
o Account Nick Name //not required – defaults to null
o Date the account was created
o Current account balance
o Account overdraft limit
o Number of transactions available for this account--- equals 2 in this example
Transaction Date --- this is the first transaction of account 1
Transaction Type
Transaction Description
Transaction Amount
Transaction Balance after transaction has been applied to account
Transaction Date --- this is the second transaction of account 1
Transaction Type
Transaction Description
Transaction Amount
Transaction Balance after transaction has been applied to account
o Account sort code --- this is the second account of customer 1
o Account Number
o Account Nick Name //not required – defaults to null
o Date the account was created
o Current account balance
o Account overdraft limit
o Number of transactions available for this account--- equals 2 in this example
Transaction Date --- this is the first transaction of account 2
Transaction Type
Transaction Description
Transaction Amount
Transaction Balance after transaction has been applied to account
Transaction Date --- this is the second transaction of account 2
Transaction Type
Transaction Description
Transaction Amount
Transaction Balance after transaction has been applied to account
• Customer ID number --- this is the second customer
• Customer title
• Customer first name
• Customer initials //not required - defaults to null
• Customer surname
• ...
• ...
• ...
Any help is VERY MUCH apreciated!
Thanks.
Ok then perhaps this will help:
Update the Customer class with a Generic Account List property.
Update the Account with a Generic Transaction List Property
Comment out your “readData()” method and replace with this:
EDIT: Comment out your “showListsOfCust” method and put this in it’s place