|
Library Card Catalog Search
The file /home/leap/cs221/book.dat contains
a list of book titles, authors and call numbers for over
400 books in the library. This is a standard text file with
one book per line in the file. The first 20 characters
on the line are the call number, the next 25 characters on
the line are the author and the remainder of the line
is the book's title which might be up to 150 characters long.
Write a class that can be used to store this list
of books, or even a larger list, using a singly linked list that has both a
front and a rear pointer. The records in the list should consist of
three information fields: call number, author and title.
The class should have member functions to perform
the following functions:
- A constructor that will initialize the list to empty.
This constructor should be called if there is no parameter (initial value)
given when an object of this type is created.
- A second constructor (overloading) that will be called if a string is
given as an initial value for the object. This string should be
taken as the name of the file of books that should be
read into the list.
- A destructor that will remove all nodes from the list and delete them.
- A function that will return the call number, author and title of the current book.
- A function to advance the current book to the next book in the list.
- A function to backup to the previous book in the list and make it the current book.
- A function to return the call number, author and title of the current book.
- A function to delete the current book from the list.
- A function to insert a new book at the end of the list.
After the file has been read into the list, your program should clear the
terminal screen and then display a program title, centered on the line at the top
of the screen. Centered approximately vertically on the screen should be three
labels on three lines double spaced with the descriptions of the three fields. At
the bottom of the screen should be a prompt for a command and a command summary
just above it. The commands that should be accepted are:
- X or Q: Exit the program
- K or W: Perform a key word search. The key word should be prompted for
and accepted then all books with that word in their title should
be included.
- N or +: Advance to the next book in the list and display it.
- P or -: Move back to the previous book in the list and display it.
- B: Jump to the first book on the list.
- E: Jump to the last book on the list.
- D: Delete the current book from the list.
- I: Insert a new book at the end of the list. The user should be
prompted for the call number, title and author of the new book.
|