You will implement a simple library catalog system in which a user can search fo
ID: 3711666 • Letter: Y
Question
You will implement a simple library catalog system in which a user can search for a book with respect to Book Title or ISBN Number. Also the administrator of the system could add a book record, delete a book record, or update book information.
? Step 1 Each record has three fields: – Book Title, – Author Name, – ISBN Number. We assume that fixed-length record size is used. So we may represent the record as the following data structure in C++: typedef struct TBook { char author[16] ; char title[24] ; char isbn[10] ; char *key(){return isbn;} } SBook ;
? Step 2 Implement add, delete, and update functions. Make sure that you consider the following situations in your design: – When you add a record, first look at the AVAIL LIST, then write the record. If there is a record available in the AVAIL LIST, write the record to a record AVAIL LIST points and make appropriate changes on the AVAIL LIST – If the record to be added already exits, do not write that record to the file – When you delete a record, do not physically delete the record from file, just put a marker on the file and make appropriate changes on AVAIL LIST – If the record to be deleted does not exist, display a warning message on the screen – The file should be compact after exiting the program, i.e. there should be no records marked as deleted in the file.
? Step 3 Implement two sorted lists, one for isbn and one for book title. Keep the lists sorted after add and delete operations.
? Step 4 Implement searching on Book Title and ISBN Number.
Explanation / Answer
#include
#include
using namespace std;
struct TBook
{ string author;
string title;
string isbn;
string available;
string key() { return isbn;};
};
class Library{
vector books;
public:
void menu(int*);
void add() {
struct TBook newBook;
cout<<"Enter book details[author, title, isbn]:"< :: iterator i;
for (i = books.begin(); i != books.end(); ++i) {
cout<<"Book Title: "<title<author<isbn< :: iterator i;
cout<<"Enter author name and title to update"<author) {
cout<<"Before update title:"<title<title = title;
cout<<"After title update:"<title< :: iterator i;
cout<<"Enter author name to search Books"<author<author) || (author.compare(i->author) == 0)) {
cout<<"Book Title: "<title<author<isbn< Quit / break;
default: input = 7; break;
}
}
return 0;
}
Input:
1
raj
"Algorithm Introduction"
12345
1
sekhar
ram
123456
2
3
raj
maths
2
Output:
Welcome! Select options below:
1.Add book.
2.Print all books.
3.Update book.
4.Sort book.
5.Delete book.
6.Search book.
7.Quit
Selection: Enter book details[author, title, isbn]:
Welcome! Select options below:
1. Add book.
2. Print all books.
3. Update book.
4. sort books.
5. Delete book.
6. search Book.
7. Quit
Selection: Enter book details[author, title, isbn]:
Welcome! Select options below:
1. Add book.
2. Print all books.
3. Update book.
4. sort books.
5. Delete book.
6. search Book.
7. Quit
Selection: Book Title: "Algorithm Introduction"
Author name: raj
ISBN:12345
----------
Book Title: ram
Author name: shekar
ISBN:12346
---------
Welcome! Select options below:
1. Add book.
2. Print all books.
3. Update book.
4. sort books.
5. Delete book.
6. search Book.
7. Quit
Selection: Enter author name and title to update
Before update title:"Algorithm Introduction"
After title update:maths
Welcome! Select options below:
1. Add book.
2. Print all books.
3. Update book.
4. sort books.
5. Delete book.
6. search Book.
7. Quit
Selection: Book Title: maths
Author name: raj
ISBN:12345
---------
Book Title: ram
Author name: shekar
ISBN:12346
---------
Welcome! Select options below:
1. Add book.
2. Print all books.
3. Update book.
4. sort books.
5. Delete book.
6. search Book.
7. Quit
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.