CMPE 352 LAB 3

advertisement
CMPE 352 LAB 3
Variable-Length Records - Slotted Page
(Week of November 17, 2008; due date November 19, 2008)
To be done in groups of 2. Pick your partner! However, you will individually be asked to
answer questions about your program.
The task:
Write a program that maintains a file of records for a library. Each record shall keep the
following information about books in the library:
Author_Name:
10 characters (Primary key)
Author_Surname:
10 characters (Primary key)
Issue_Date: 8 characters (DD-MM-YYYY) (Primary key)
Title:
character string with at least 8 and at most 40 characters
Each record may have a size in the range 36..68 bytes. Use the Slotted Page Structure
(Textbook, Figure 11.9, p. 467; Slide 11.43) for organizing the contents of the blocks in
the file.
A block is organized as follows. Each block should have 209 bytes. The first three bytes
in the block keep the address (the byte number as ASCII digits to be readable) of the
end of free space. The fourth byte in the block keeps the number of entries in the block.
Each entry in the block header for records stored in the block takes five bytes. The first
three bytes keep the address of the start byte of the record and the last two keep the
record size. According to these specifications, the maximum number of the records that
fit in a block is five (5x36+5x5+4=209 bytes). If a block is free, preserve it in the file.
Menu
Your program should have menu with the following commands:
1.
2.
3.
4.
Insert record
List all the records (will show the records on the screen)
Delete record (will ask for the Author_Name, Author_Surname, Issue_date)
Exit
The file should be a text file that is readable by humans! The contents of the file will be
checked before your program runs, and also after it is finished.
Grading Policy: 40% for program functionality, 60% for answering
questions
Download