I’m currently working on a java project that requires me to make a system for an ATM. I have classes for userList, userNode; each user node contains accountList with accountNode (the accountNode has children classes for types of accounts, such as credit or debit) and the account node contains an operationList with nodes for withdraw, deposit, etc…
I need to be able to read and save to an object file. So I don’t lose the data when quitting the program or have to create new users, accounts, etc every time the program runs. However, I’m not sure if I need a new class for creating the object file or what ways there are to do this.
I’d appreciate any suggestions.
Database would be the best and the most real world solution for this but if you do want to write and read from a file, you will need to make your classes implement Serializable. From there you can look up several tutorials on writing and reading those objects back from a file.
http://java.sun.com/developer/technicalArticles/Programming/serialization/
If you want to work with a database, go get MySQL or something free.
http://dev.mysql.com/downloads/