1 public class BankDatabase
\r
5 BankAccount[] database;
\r
8 public BankDatabase()
\r
10 //6 pre-created accounts
\r
14 database = new BankAccount[10];
\r
16 for(int i = 0; i < 10; i++)
\r
18 database[i] = new BankAccount();
\r
21 //some hardcoded values
\r
22 database[0].modifyAccount("123456789", "John@@@@@@", "Q@@@@@@@@@", "Public@@@@", "1", "256000001@", "2007");
\r
23 database[1].modifyAccount("987654321", "Nancy@@@@@", "H@@@@@@@@@", "Private@@@", "2", "166@@@@@@@", "1234");
\r
24 database[2].modifyAccount("000111000", "Paul@@@@@@", "Wellington", "Franks@@@@", "1", "454225@@@@", "0000");
\r
25 database[3].modifyAccount("211411911", "Felix@@@@@", "the@@@@@@@", "Cat@@@@@@@", "3", "0@@@@@@@@@", "9999");
\r
26 database[4].modifyAccount("111000111", "Paul@@@@@@", "Wellington", "Franks@@@@", "2", "1128989@@@", "0000");
\r
28 database[5].modifyAccount("@@@@@@@@@", "@@@@@@@@@@", "@@@@@@@@@@", "@@@@@@@@@@", "@", "@@@@@@@@@@", "@@@@");
\r
29 database[6].modifyAccount("@@@@@@@@@", "@@@@@@@@@@", "@@@@@@@@@@", "@@@@@@@@@@", "@", "@@@@@@@@@@", "@@@@");
\r
30 database[7].modifyAccount("@@@@@@@@@", "@@@@@@@@@@", "@@@@@@@@@@", "@@@@@@@@@@", "@", "@@@@@@@@@@", "@@@@");
\r
31 database[8].modifyAccount("@@@@@@@@@", "@@@@@@@@@@", "@@@@@@@@@@", "@@@@@@@@@@", "@", "@@@@@@@@@@", "@@@@");
\r
32 database[9].modifyAccount("@@@@@@@@@", "@@@@@@@@@@", "@@@@@@@@@@", "@@@@@@@@@@", "@", "@@@@@@@@@@", "@@@@");
\r
34 //test read into database[5]
\r
37 //test write from database[5]
\r
38 WriteFile(database[5].AccountNumber, database[5].FirstName, database[5].MiddleName, database[5].LastName, database[5].AccountType, database[5].Balance, database[5].PIN);
\r
41 /* what, no destructor?
\r
42 public ~BankDatabase()
\r
44 //test write from database[5]
\r
47 public void ReadFile(int index)
\r
49 //need to check if read/write works the way I think it does
\r
50 String filename="BankAppRead.dat";
\r
51 FileInputStream fis = new FileInputStream(filename);
\r
53 byte account[] = new byte[9];
\r
54 byte first[] = new byte[10];
\r
55 byte middle[] = new byte[10];
\r
56 byte last[] = new byte[10];
\r
57 byte type[] = new byte[1];
\r
58 byte balance[] = new byte[10];
\r
59 byte pin[] = new byte[4];
\r
61 //read one account for now
\r
72 String S1 = new String(account);
\r
73 //System.printString(S1);
\r
74 String S2 = new String(first);
\r
75 //System.printString(S2);
\r
76 String S3 = new String(middle);
\r
77 //System.printString(S3);
\r
78 String S4 = new String(last);
\r
79 //System.printString(S4);
\r
80 String S5 = new String(type);
\r
81 //System.printString(S5);
\r
82 String S6 = new String(balance);
\r
83 //System.printString(S6);
\r
84 String S7 = new String(pin);
\r
85 //System.printString(S7);
\r
87 //read into one account for now
\r
88 database[index].modifyAccount(S1, S2, S3, S4, S5, S6, S7);
\r
91 public void WriteFile(String account, String first, String middle, String last, String type, String balance, String pin)
\r
93 String filename="BankAppWrite.dat";
\r
94 FileOutputStream fos = new FileOutputStream(filename);
\r
96 //write one account for now
\r
97 fos.write(account.getBytes());
\r
98 fos.write(first.getBytes());
\r
99 fos.write(middle.getBytes());
\r
100 fos.write(last.getBytes());
\r
101 fos.write(type.getBytes());
\r
102 fos.write(balance.getBytes());
\r
103 fos.write(pin.getBytes());
\r