| Introduction to Computer Science I by James Tam | Return to the course web page |
For this assignment you are to write a Pascal program that allows a person to manage their book collection. In the full version of the assignment your program will read the initial information about the collection from file called 'books.dat' into an array of records. The user can perform all the common list management functions, such as removing books from the collection or inserting new books into the collection. When the person has finished with the program, he or she can then save the updated information back to the data file and reload that information back to the collection.
Each book will be described by four fields with each field residing on a separate line in the input file:
| 1. | JT: The rating value given to the books in the input file was based solely upon my opinion and does not necessarily reflect the opinions of the university so please don't write angry letters outrage because you thought I didn't properly rate your favourite book☺. |
The four main fields for each book will be followed by an empty line (to be specific it's the end-of-line marker):
THE UNIVERSE IN A NUTSHELL
Stephen Hawking
IN
8
A CHRISTMAS CAROL
Charles Dickens
FI
10
DRACULA
Bram Stoker
HO
10
THE QUEEN'S FOOL: A Novel
Philippa Gregory
FI
6
THUNDER RUN: THE ARMOURED STRIKE TO TAKE BAGHDAD
David Zucchino
NF
10
Your program reads the information from the input file 'books.dat' into the array. The contents of that array can be displayed onscreen with write's and writeln statements with each book separated by a line of stars. To prevent the output from scrolling off the screen your program should 'pause' the display of books ever so often (say after displaying every 5th or 6th book) while it waits for a response from the user to tell it to continue (e.g., 'Hit enter to continue'). The output must be displayed in a neat and legible format that clearly labels each field of each book (try running the sample executable for an example of how your output could look). Finally your program must be able to write the information for the book collection back to a file. The user should be able to specify the name of the input and output file as the program runs. The line of stars that separated each book when displayed onscreen should not be written to this file but an empty line should be written instead (i.e., the format of the output file should be the same as the books.dat input file). Similar to previous assignments, your program has menu driven interface. The basic program should display a menu similar to the one shown below:
Book Manager: Menu options
(d)isplay collection
(l)oad a collection from a file
(s)ave the collection to a file
(q)uit the program
You should add additional menu options as you implement the extra features that are listed below.
Missing the features listed above: You have the potential to receive a maximum grade of 'C' if you implement all of the above features. If features are missed or improperly implemented then your mark may be reduced by a letter step for each feature that is missed (down to a minimum grade of a 'D' assuming of course that it actually compiles):
Completion of each of these extra features will result in the increase of a "one step" to your grade e.g., 'C' to 'C+'. Unless there is a compelling reason to do otherwise you may complete as many of the features below as you wish in whatever combination that you desire. Successful completion of all six features will make you eligible for an 'A'. (You must also fulfill style requirements as well as the general submission assignment requirements).
Feature one (Alphabetize the list according to titles):
Sort the list into alphabetical order according to the name of the book.
Feature two (Find additional details about a book):
The user of the program can type in the title (case sensitive) in order to find additional information about that book . If the book is not in the list, then your program should indicate that no book could not be found under that title. If the book is in the list, then your program will display additional details about that book (all the fields will be displayed onscreen).
Feature three (Present all books of a certain genre):
This feature allows the user of the program to display the titles of all of the books of a particular genre (alternatively you can get your program to show all titles that were written by a particular author or with a specific rating but since these operations are very similar you will only get a maximum credit of one grade step for this feature regardless of how many criteria that your program can use as presentation criteria).
If you have already completed feature one, then the books will be presented in alphabetical order, otherwise they will presented in the order in which they currently appear in the array.
Feature four (Insert a book at the end of the list):
When this feature is selected by the user, he or she will prompted to enter in information for all the fields of the new book which will then be added to the end of the list.
Feature five (Remove a book from the list):
Since the user must type in the name of the book in order to indicate which book that he or she wishes to remove from the list you will likely have already completed the 'find' feature first (feature two). When the collection is displayed after the removal, no information about the book that was removed should be displayed - not even blank spaces. You can implement this feature by either shifting 'up' the array elements that follow the element to be deleted or you may be able to add an additional field for each array element that indicates whether it has been deleted or not (JT: I'd recommend the first approach because you'll probably find it easier to implement).
Feature six (Write an enhanced Save feature)
In order to get credit for this feature, the program will now use only one data file. The program will load the site information from the 'books.dat' file. When the user of the program selects the 'save' option then the program can write the modifications to the 'books.dat' file rather than a separate file. To get credit for this feature your program must be able to reload the updated information from the modified file. This latter requirement means that your program must write the information to disk in the exact same format that it was originally stored. If there any differences from the original data file and the modified version your program will not be able to properly read it back into the array.
D level assignment
The student has invested considerable work in the assignment and the code compiles but it doesn't fulfill any of the above requirements.
D- level assignment
The student has invested considerable work in the assignment but it doesn't compile.