Java Programming Project 2: RandomAccessFile class
Objective:
Write a program that uses the RandomAccessFile class to create a simple bank
management system. The program will store fixed-length bank records in a binary file. A
bank record will store the account number (int), the account holder's name (30
characters), and the account balance (double).
Provided Classes:
BankRecord Class (Provided)
This class defines the data structure for a bank record and includes methods to read and
write a record to and from a file. Do not modify this class.
BankManagement Class (To Be Implemented)
This class defines the methods to process bank records. Implement the following
methods:
1. addRecord: Adds a bank record at the "end" of the file. Displays a message
indicating the record was added.
2. viewAllRecords: Displays all the bank records in the file on the console. Note:
Records "marked" as deleted shouldn't be displayed.
3. deleteRecord: Marks a bank record as deleted by setting its account number to -1.
Additionally, clears the customer's name by padding it completely with spaces and
sets the balance to 0.0. Displays a message indicating the record was deleted. If the
bank record is not found, displays a message.
4. modifyRecord: Overwrites an existing bank account record with new data. Displays
a message indicating the record was modified. If the bank record is not found,
displays a message.
5. searchRecord: Searches for the bank record having the specified account number.
If the account number is found, returns the corresponding bank record. If the
account number is not found or the account number is -1, returns null.
6. close: Closes the file containing the bank records.
BankManagementApp Class (Provided)
This class simulates the bank management system and is used to test the
BankManagement class. Do not modify this class.
Requirements:
1. The provided BankRecord class must be used to represent a bank record and should
not be altered.
2. The signatures of the methods in the BankManagement class shouldn't be modified
when implementing the methods.
3. The provided BankManagementApp class should not be altered.
4. All 3 classes should be implemented in one Java file.
Submission:
Submit a single Java file containing the implementation of the BankRecord,
BankManagement, and BankManagementApp classes.
Rubric
addRecord (20 points)
• 0 points: Method not implemented or incorrect implementation.
• 10 points: Method adds a bank record at the end of the file but with issues (e.g.,
incorrect handling of data).
• 20 points: Method correctly adds a bank record at the end of the file and displays a
message indicating the record was added.
viewAllRecords (20 points)
• 0 points: Method not implemented or incorrect implementation.
• 10 points: Method displays records but includes deleted records or misses some
records.
• 20 points: Method correctly displays all non-deleted bank records in the file on the
console.
deleteRecord (20 points)
• 0 points: Method not implemented or incorrect implementation.
• 10 points: Method marks a record as deleted but with issues (e.g., incorrect data
clearing).
• 20 points: Method correctly marks a bank record as deleted, clears the name, sets
the balance to 0.0, and displays a message indicating the record was deleted.
Handles the case when the record is not found.
modifyRecord (20 points)
• 0 points: Method not implemented or incorrect implementation.
• 10 points: Method modifies a record but with issues (e.g., incorrect data handling).
• 20 points: Method correctly overwrites an existing bank account record with new
data and displays a message indicating the record was modified. Handles the case
when the record is not found.
searchRecord (10 points)
• 0 points: Method not implemented or incorrect implementation.
• 5 points: Method searches for a record but returns incorrect results.
• 10 points: Method correctly searches for the bank record with the specified account
number and handles cases where the record is not found or deleted.
close (10 points)
• 0 points: Method not implemented or incorrect implementation.
• 5 points: Method closes the file but with issues.
• 10 points: Method correctly closes the file containing the bank records.
Total: 100 points