Question: Objectives For this programming project, you will develop a library management program that maintains the library book list and the library client (i.e., customer) list,
Objectives
For this programming project, you will develop a library management program that maintains the library book list and the library client (i.e., customer) list, as well as the interactions between the two lists. The program allows the librarian to add copies of books, add clients, let a client check out (i.e., borrow) books, and let a client check in (i.e., return) books.
Problem Description
In this programming assignment, you will develop a project that implements an engineering library (or any other library; engineering library is mentioned because all the books I currently include are engineering textbooks). You will implement and test four classes in this assignment. They are the BookType, BookRecord, ClientType, and LibraryType classes. You are to write the an implementation file: BookType.cpp. In the following, we will discuss each class in more detail.
The BookType Class
Each object of the BookType class contains the related information of a book. The BookType.h file is given to you. Carefully read the class definition in BookType.h. The BookType class has five protected data members. They are: a string ISBN13 to store the 13-digit ISBN of a book; a string primaryAuthor to store the primary authors last name; a string title to store the book title; a string publisher to store the publishers name; and an integer key to indicate the key member used for searching and sorting.
You are to implement and test the following operations for the BookType class. Detailed description and precondition/postcondition for all the BookTypes member functions are specified in the given header file.
A constructor.
Five set functions: setISBN13, setPrimaryAuthor, setTitle, setPublisher, setKey.
A setBookInfo function.
Five get functions: getISBN13, getPrimaryAuthor, getTitle, getPublisher, getKey.
The six comparison operators.
The operator << (as a friend function).
This is the .h File:
//**********************************************************
// SPECIFICATION FILE (BookType.h)
// This class specifies the basic members to implement a book.
//**********************************************************
#ifndef BOOKTYPE_H
#define BOOKTYPE_H
#include
#include
using namespace std;
class BookType; // Forward Declaration
ostream& operator <<(ostream&, const BookType&);
class BookType
{
public:
// Constructor
BookType(string s1 = "", string s2 = "", string s3 = "",
string s4 = "", int k = 1);
// The member variables are set according to the incoming
// parameters. If no values are specified, the default values
// are assigned. (By default, we set key=1, i.e., we set the ISBN
// as the key member since it is different for different books;
// so it is also used in the role of primary key for a list of books.)
// Post: ISBN13= s1; primaryAuthor = s2; title = s3;
// publisher = s4; key = k;
// Action responsibilities
void setISBN13(string s);
// Function to set the ISBN-13 of a book.
// Post: ISBN13 = s;
void setPrimaryAuthor(string s);
// Function to set the primary author's last name of a book.
// Post: primaryAuthor = s;
void setTitle(string s);
// Function to set the title of a book.
// Post: title = s;
void setPublisher(string s);
// Function to set the publisher of a book.
// Post: publisher = s;
void setKey(int k);
// Function to set the key of a book. (When key==1, set ISBN13
// as the key member; when key==2, set primaryAuthor as the key;
// when key==3, set title as the key; when key==4, set publisher
// as the key.)
// Post: key = k;
void setBookInfo(string s1, string s2, string s3, string s4, int k = 1);
// Function to set the member variables according to the incoming
// parameters. (By default, we set key=1, i.e., we set the ISBN
// as the key member.)
// Post: ISBN13 = s1; primaryAuthor = s2; title = s3;
// publisher = s4; key = k;
// Knowledge responsibilities
string getISBN13() const;
// Function to check the book's ISBN-13.
// Post: The value of ISBN13 is returned.
string getPrimaryAuthor() const;
// Function to check the primary author's last name.
// Post: The value of primaryAuthor is returned.
string getTitle() const;
// Function to check the book title.
// Post: The value of title is returned.
string getPublisher() const;
// Function to check the publisher's name.
// Post: The value of publisher is returned.
int getKey() const;
// Function to check the book's key.
// Post: The value of key is returned.
// Overloaded the relational operators
bool operator==(const BookType& otherBook) const;
// Overloaded operator==
// Post: Return 1 if and only the two books' ISBN-13 are the same;
// otherwise, return 0.
bool operator!=(const BookType& otherBook) const;
// Overloaded operator!=
// Post: Return 1 if and only the two books' ISBN-13 are different;
// otherwise, return 0.
bool operator<(const BookType& otherBook) const;
// Overloaded operator<
// Post: When key==1, return 1 if and only ISBN13 // otherwise, return 0. // When key!=1, return 1 if, // (a) corresponding key member of the current object < // corresponding key member of otherBook // OR // (b) corresponding key member of the current object == // corresponding key member of otherBook // and ISBN13 // otherwise, return 0. bool operator<=(const BookType& otherBook) const; // Overloaded operator<= // Post: When key==1, return 1 if and only ISBN13<=otherBook.ISBN13; // otherwise, return 0. // When key!=1, return 1 if, // (a) corresponding key member of the current object < // corresponding key member of otherBook // OR // (b) corresponding key member of the current object == // corresponding key member of otherBook // and ISBN13<=otherBook.ISBN13; // otherwise, return 0. bool operator>(const BookType& otherBook) const; // Overloaded operator> // Post: When key==1, return 1 if and only ISBN13>otherBook.ISBN13; // otherwise, return 0. // When key!=1, return 1 if, // (a) corresponding key member of the current object > // corresponding key member of otherBook // OR // (b) corresponding key member of the current object == // corresponding key member of otherBook // and ISBN13>otherBook.ISBN13; // otherwise, return 0. bool operator>=(const BookType& otherBook) const; // Overloaded operator>= // Post: When key==1, return 1 if and only ISBN13>=otherBook.ISBN13; // otherwise, return 0. // When key!=1, return 1 if, // (a) corresponding key member of the current object > // corresponding key member of otherBook // OR // (b) corresponding key member of the current object == // corresponding key member of otherBook // and ISBN13>=otherBook.ISBN13; // otherwise, return 0. // Friend function friend ostream& operator<<(ostream& outs, const BookType& book); // Overloaded operator << for the BookType class. // Post: The book information is written to the input ostream instance. // The return value is the input ostream instance. The format of output // is as follows: // (First leave one empty line) // ISBN-13: (Display the book's ISBN13 in this line.) // Primary Author: (Display the book's primaryAuthor in this line.) // Title: (Display the book's title in this line.) // Publisher: (Display the book's publisher in this line.) // (Finally dispaly a line with "--------------------------------") protected: string ISBN13; // variable to store ISBN-13, using string rather than // int allows for the leading 0's to show up in the 13 digits string primaryAuthor; // variable to store the primary author's // last name string title; // variable to store the title of the book string publisher; // variable to store the publisher's name int key; // to indicate the key member used for searching and sorting. // When key==1, set ISBN13 as the key member; when key==2, set // primaryAuthor as the key; when key==3, set title as the key; // when key==4, set publisher as the key. }; #endif
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
