Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // File: book.h
- // Programmer:
- // Class: COP 2931
- // Description: This program simulates the checking out and checking in of books
- // from a library
- #ifndef BOOK_H
- #define BOOK_H
- #include <iostream>
- #include <iomanip>
- #include <string>
- using namespace std;
- class Book
- {
- public:
- // Constructors
- Book();
- Book(string title, string author, int bookID);
- void changeHold(int holderID); // Assign current holder
- void resetHold(); // Reset hold status
- void getInfo(); // Print book information
- string getTitle(); // Return title
- string getAuthor(); // Return author
- int whoHas(); // Return holderID
- int getID(); // Return bookID
- bool getStatus(); // Check if book is available for checkout
- bool checkInit(); // Check if book is properly initialized
- private:
- string title;
- string author;
- int bookID;
- int holderID;
- bool Checked;
- };
- Book::Book()
- {
- holderID = -1; // Sentinel value to indicate improper initialization
- }
- Book::Book(string title, string author, int bookID)
- {
- this->title = title;
- this->author = author;
- this->bookID = bookID;
- holderID = 0;
- Checked = false;
- }
- void Book::changeHold(int holderID)
- {
- this->holderID = holderID;
- Checked = true;
- }
- void Book::resetHold()
- {
- holderID = 0;
- Checked = false;
- }
- void Book::getInfo()
- {
- cout.width(8); cout << "Title: " << title << endl;
- cout.width(8); cout << "Author: " << author << endl;
- cout.width(8); cout << "ID: " << bookID << endl;
- cout.width(8); cout << "Status: ";
- if (holderID == 0)
- {
- cout << "AVAILABLE" << endl;
- }
- else
- {
- cout << "CHECKED OUT" << endl;
- }
- }
- string Book::getTitle()
- {
- return title;
- }
- string Book::getAuthor()
- {
- return author;
- }
- int Book::whoHas()
- {
- return holderID;
- }
- int Book::getID()
- {
- return bookID;
- }
- bool Book::getStatus()
- {
- return Checked;
- }
- bool Book::checkInit()
- {
- if(holderID == -1) return 0;
- else return 1;
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement