Create a Small Library Inventory Program that Checks In and Out Book
Question Description
Hello, I need help creating a project with the following features in C++:
-The Book class counts the number of times a book has been checked
out. -The Library class contains a collection of Book instances.
-New books are added to the collection of the Library class through the calls to addbookintoCollection( ).
-The books are allowed to be checked out by calls to bookCheckout( ) in the library class.
-Subclass via inheritances std::logic_error to create bookNotAvailable errors when users attempt to create errors.
-Only want to provide the public API.
Here is the outline to follow:
class Library
{
public:
library();
void addbookintoCollection( string author, string title );
void bookCheckout( string author, string title ) throw (bookNotAvailable);
void bookCheckin( string author, string title ) throw (bookNotAvailable);
friend operator<< ( ostream& out, const Library & l );
private:
Book myBooks[ 20 ];
int numberOfbooksSeenthusfar;
}
class Book
{
public:
Book();
Book( string author, string title );
string getAuthor() const;
string getTitle() const;
int getNumberCheckedOut() const;
void increaseNumberCheckedOut( int amount=1 );
friend operator<< ( ostream& out, const Book & b );
private:
string theAuthor;
string theTitle;
int theNumberCheckedOut;
}
Here is the driver code:
Library lib;
lib.addBookToCollection( “F. Scott Fitzgerald”, “The Great Gatsby” );
lib.addBookToCollection( “J. D. Salinger”, “The Catcher in the Rye” );
cout << lib << endl;
try {
lib.bookCheckout( “J. D. Salinger”, “The Catcher in the Rye” );
lib.bookCheckin( “J. D. Salinger”, “The Catcher in the Rye” );
lib.bookCheckout( “F. Scott Fitzgerald”, “The Great Gatsby” );
} catch(bookNotAvailable notava ) {
cout << “You have entered the incorrect:”;
cout << notava.goof() << endl;
}
Thanks for the help
This question has not been answered.
Create a free account to get help with this and any other question!
Brown University
1271 Tutors
California Institute of Technology
2131 Tutors
Carnegie Mellon University
982 Tutors
Columbia University
1256 Tutors
Dartmouth University
2113 Tutors
Emory University
2279 Tutors
Harvard University
599 Tutors
Massachusetts Institute of Technology
2319 Tutors
New York University
1645 Tutors
Notre Dam University
1911 Tutors
Oklahoma University
2122 Tutors
Pennsylvania State University
932 Tutors
Princeton University
1211 Tutors
Stanford University
983 Tutors
University of California
1282 Tutors
Oxford University
123 Tutors
Yale University
2325 Tutors