960679#Darwin, Charles#Biology
8008765#Wareham, Todd#Computer Science
008765#Schweitzer, Albert#Medicine
160011#Einstein, Albert#Physics
This file has 4 entries and 3 fields per entry; field 2 of entry 3 is "Schweitzer, Albert" and field 3 if entry 4 is "Physics". Such database files are known as flat files.
In this assignment, you will implement both a generic flat file class and a class that uses this generic class to implement a password database.
These methods should be the only publicly-accessible elements in this class. Note that all of these methods throw exception IOException to account for basic I/O errors not dealt with by this class, e.g., file permissions changing in mid-execution. Where necessary, various methods can use a temporary flatfile called filename.temp; however, if such a file is created in a method, it must be destroyed by the time that method terminates. This class must be the only class-definition contained in file FlatFile.java.
These methods should be the only publicly-accessible elements in this class. Note that all of these methods throw exception IOException to account for basic I/O errors not dealt with by this class, e.g., file permissions changing in mid-execution. Note also that where necessary, certain exceptions thrown by flatfile methods are "absorbed" and not thrown by the methods above. This class must be the only class-definition contained in file PasswordDb.java. You will be given the following:
Fill in missing details and fully comment the code in FlatFile.java; places where you need to fill in code are denoted by the inline comment "*** PERFORM MAGIC HERE ***". All other given Java files are complete as they are. You will have to write your own file containing the class-definition of PasswordDb as described above.
IMPORTANT: As your submitted code will be tested using programs that assume the classes and methods described above, the classes in your submitted code must be named and all methods in these classes must be defined EXACTLY as specified above. Submitted code not conforming to these specifications will not be tested and marks will be deducted accordingly.
Adding a line to a file is much easier if writing is done using the append version of the constructor for the FileWriter class.
Various methods in class File, e.g., renameTo, delete, are very handy not only for querying files existence or permissions but also for performing LINUX shell operations on files like renaming or deletion.
Each PasswordDb object will should have an associated flatfile object.
Remembering whether or not a PasswordDb object has been loaded or not can be done very easily using a private boolean variable loaded; such a variable should be initialized to false when the object is created, its value modified accordingly by methods load and save, and its value checked by all other methods as necessary.
You may use any data structures you wish to implement the storage for the password database inside a PasswordDb object. May I suggest using a pair of vectors to store the passwords and names, respectively.
See appropriate web pages for instructions on compiling and running Java programs.
Please submit your program files FlatFile.java and PasswordDb.java using system program submit-assignment by the due date. No hardcopies of these files need to be passed in to me. NOTE: If you are using non-standard classes for input or output, e.g., Keyboard, EasyReader, please submit files containing theses class definitions along with the requested Java files.
Created: October 10, 2000
Last Modified: October 13, 2000