CMPE 352 LAB 3

advertisement
CMPE 352 LAB 3
Variable-Length Records - Slotted Page
(Week of March 24, 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 an office. Each record shall keep the
following information about teachers in a department:
Name:
10 characters (Primary key)
Surname:
10 characters (Primary key)
Birthday:
8 characters (DD-MM-YYYY)
Position:
a set of 1 to 2 items 20 characters each (e.g., three variants are below:
(‘Assoc Prof’, ‘Chair’), (‘Assist Prof’, ‘Vice-Chair’, (‘Visit Assoc Prof’))
Each record may have a size of 48 or 68 bytes. Use the Slotted Page Structure
(Textbook, Figure 11.9, p. 467) for organizing the contents of the blocks in the file.
A block is organized as follows. Each block should have 269 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 (5x48+5x5+4=269 bytes). İf Position has two items, only three
records fit a block: 3x68+3x5+4=217 bytes, hence, 52 bytes in this case are idle. 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 Name and Surname)
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