In this programming assignment you will write a program that uses two classes. When you are finished you should have five files: main.cpp, book.h, book.cpp, library.h, and library.cpp. Your class declarations should go in your .h files and your implementation should go in your .cpp files. The following is a summarization of the two classes and your main.cpp.

Before writing your code, you should make a UML class diagram for the book and library classes.

Book Class

The book class will have five attributes: ISBN, title, author, and check out status. The class should have a constructor that takes parameters for ISBN, title, author first name, and author last name (you should keep these in separate fields since you will eventually need to sort the books by author last name). By default, a book should not be checked out when created. You should have getters for each attribute and a setter for the checked out status. Make sure that you place your class declaration in book.h and all the implementation code in book.cpp.

Library Class

The library class will include a vector of books (from the book class above). The class should have the following methods each doing as described:

  • loadBooks(string fileName) this method should take a string that is the name of a file. It should read through the file and create a book for each book in the file and add the book to the books vector.
  • addBook(Book book) this method should take a single book object and add it to the books vector
  • checkBookOut(string ISBN) this method should search through the books vector for a book that matches the ISBN. If found the checked out status should be changed to checked out. If the book is already checked out an appropriate message should be displayed. If the book is not found an appropriate message should be displayed.
  • checkBookIn(string ISBN) this method should search through the books vector for a book that matches the ISBN. If found the checked out status should be changed to checked in. If the book is already checked in an appropriate message should be displayed. If the book is not found an appropriate message should be displayed.
  • printBookList() this method should print out a list of books held in the library by authors last name. The list should be printed as a table with one book per row. Print the authors name (last name, first name), the title of the book, and the ISBN number.

You should have two constructors for the library class:

  • Default constructor does nothing
  • Library(string fileName) this constructor takes a single parameter, a file name. It should call loadBooks(fileName) with the file name that was passed to the constructor.

main.cpp

The function main.cpp will be provided for you. You should not need to make any modifications to this function. What

A possible sample run will look as follows:

Main Menu
1. Print Book List
2. Check out a book
3. Check in a book
4. Add a book
5. Quit
Enter your choice (1-5): 1
Author Name Book Title ISBN Availability
-------------------------------------------------------------------------------------
Gookin, Dan C for Dummies, Volume 1 1878058789 In
Griggiths, David Head First C 1449399916 In
Jones, Bradley C Programming in One Hour a Day 0789751992 In
Kalicharan, Noel C Programming - An Advanced Course 1438275579 In
Kernighan, Brian The C Programming Language 0131103628 In
King, K C Programming: A Modern Approach 0393979504 In
Kochan, Stephen Programming in C 0672326663 In
Linden, Peter Expert C Programming: Deep C Secrets 0131774298 In
McGrath, Mike C Programming in Easy Steps 1840785446 In
Oualline, Steve Practical C Programming 1565923065 In
Perry, Greg C Programming Absolute Beginners Guide 0789751984 In
Perry, Greg Absolute Beginner's Guide to C 0672305100 In
Prata, Stephen C Primer Plus 0321928423 In
Reese, Richard Understanding and Using C Pointers 1449344186 In
--------------------------------------------------------------------------------------
Press any key to continue . . .
Main Menu
1. Print Book List
2. Check out a book
3. Check in a book
4. Add a book
5. Quit
Enter your choice (1-5): 2
Enter the ISBN of the book to ckeck out: 1878058789
Check out successful
Press any key to continue . . .
Main Menu
1. Print Book List
2. Check out a book
3. Check in a book
4. Add a book
5. Quit
Enter your choice (1-5): 2
Enter the ISBN of the book to ckeck out: 123456
123456 not found
Press any key to continue . . .
Main Menu
1. Print Book List
2. Check out a book
3. Check in a book
4. Add a book
5. Quit
Enter your choice (1-5): 1
Author Name Book Title ISBN Availability
-------------------------------------------------------------------------------------
Gookin, Dan C for Dummies, Volume 1 1878058789 Out
Griggiths, David Head First C 1449399916 In
Jones, Bradley C Programming in One Hour a Day 0789751992 In
Kalicharan, Noel C Programming - An Advanced Course 1438275579 In
Kernighan, Brian The C Programming Language 0131103628 In
King, K C Programming: A Modern Approach 0393979504 In
Kochan, Stephen Programming in C 0672326663 In
Linden, Peter Expert C Programming: Deep C Secrets 0131774298 In
McGrath, Mike C Programming in Easy Steps 1840785446 In
Oualline, Steve Practical C Programming 1565923065 In
Perry, Greg C Programming Absolute Beginners Guide 0789751984 In
Perry, Greg Absolute Beginner's Guide to C 0672305100 In
Prata, Stephen C Primer Plus 0321928423 In
Reese, Richard Understanding and Using C Pointers 1449344186 In
--------------------------------------------------------------------------------------
Press any key to continue . . .
Main Menu
1. Print Book List
2. Check out a book
3. Check in a book
4. Add a book
5. Quit
Enter your choice (1-5): 4
Enter the ISBN of the book: 1111111111
Enter the last name of the author: Seuss
Enter the first name of the author: Doctor
Enter the title of the book: Green Eggs and Ham
Press any key to continue . . .
Main Menu
1. Print Book List
2. Check out a book
3. Check in a book
4. Add a book
5. Quit
Enter your choice (1-5): 1
Author Name Book Title ISBN Availability
-------------------------------------------------------------------------------------
Gookin, Dan C for Dummies, Volume 1 1878058789 Out
Griggiths, David Head First C 1449399916 In
Jones, Bradley C Programming in One Hour a Day 0789751992 In
Kalicharan, Noel C Programming - An Advanced Course 1438275579 In
Kernighan, Brian The C Programming Language 0131103628 In
King, K C Programming: A Modern Approach 0393979504 In
Kochan, Stephen Programming in C 0672326663 In
Linden, Peter Expert C Programming: Deep C Secrets 0131774298 In
McGrath, Mike C Programming in Easy Steps 1840785446 In
Oualline, Steve Practical C Programming 1565923065 In
Perry, Greg C Programming Absolute Beginners Guide 0789751984 In
Perry, Greg Absolute Beginner's Guide to C 0672305100 In
Prata, Stephen C Primer Plus 0321928423 In
Reese, Richard Understanding and Using C Pointers 1449344186 In
Seuss, Doctor Green Eggs and Ham 1111111111 In
--------------------------------------------------------------------------------------
Press any key to continue . . .
Main Menu
1. Print Book List
2. Check out a book
3. Check in a book
4. Add a book
5. Quit
Enter your choice (1-5): 3
Enter the ISBN of the book to check in: 1878058789
Check in successful
Press any key to continue . . .
Main Menu
1. Print Book List
2. Check out a book
3. Check in a book
4. Add a book
5. Quit
Enter your choice (1-5): 1
Author Name Book Title ISBN Availability
-------------------------------------------------------------------------------------
Gookin, Dan C for Dummies, Volume 1 1878058789 In
Griggiths, David Head First C 1449399916 In
Jones, Bradley C Programming in One Hour a Day 0789751992 In
Kalicharan, Noel C Programming - An Advanced Course 1438275579 In
Kernighan, Brian The C Programming Language 0131103628 In
King, K C Programming: A Modern Approach 0393979504 In
Kochan, Stephen Programming in C 0672326663 In
Linden, Peter Expert C Programming: Deep C Secrets 0131774298 In
McGrath, Mike C Programming in Easy Steps 1840785446 In
Oualline, Steve Practical C Programming 1565923065 In
Perry, Greg C Programming Absolute Beginners Guide 0789751984 In
Perry, Greg Absolute Beginner's Guide to C 0672305100 In
Prata, Stephen C Primer Plus 0321928423 In
Reese, Richard Understanding and Using C Pointers 1449344186 In
Seuss, Doctor Green Eggs and Ham 1111111111 In
--------------------------------------------------------------------------------------
Press any key to continue . . .
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.