Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // File: card.h
- // Programmer: Robert Doobay
- // Class: COP 2931
- // Description: This program simulates the checking out and checking in of books
- // from a library. Book data and library card data is read in from books.txt
- // and cards.txt and stored in separate arrays of their respective object types.
- // When the program user is finished making changes to the database, the
- // existing text files are deleted and new ones are created to reflect all
- // changes made.
- #ifndef CARD_H
- #define CARD_H
- #include <iostream>
- #include <string>
- using namespace std;
- class Card
- {
- public:
- // Constructors
- Card();
- Card(string name, string phone, int holderID);
- void changeBook(int bookID); // Assign current book
- void resetHold(); // Reset hold status
- void getInfo(); // Print card information
- string getName(); // Return name
- string getPhone(); // Return phone
- int getID(); // Return holderID
- int getBook(); // Return bookID
- bool getStatus(); // Check if card has a book checked out
- bool checkInit(); // Check if card is properly initialized
- private:
- string name;
- string phone;
- int holderID;
- int bookID;
- };
- Card::Card()
- {
- bookID = -1; // Sentinel value to indicate improper initialization
- }
- Card::Card(string name, string phone, int holderID)
- {
- this->name = name;
- this->phone = phone;
- this->holderID = holderID;
- bookID = 0;
- }
- void Card::changeBook(int bookID)
- {
- this->bookID = bookID;
- }
- void Card::resetHold()
- {
- bookID = 0;
- }
- void Card::getInfo()
- {
- cout.width(8); cout << "Name: " << name << endl;
- cout.width(8); cout << "Phone: " << phone << endl;
- cout.width(8); cout << "ID: " << holderID << endl;
- }
- string Card::getName()
- {
- return name;
- }
- string Card::getPhone()
- {
- return phone;
- }
- int Card::getID()
- {
- return holderID;
- }
- int Card::getBook()
- {
- return bookID;
- }
- bool Card::getStatus()
- {
- if (bookID == 0) return 0;
- else return 1;
- }
- bool Card::checkInit()
- {
- if(bookID == -1) return 0;
- else return 1;
- }
- #endif
Add Comment
Please, Sign In to add comment