Develop a C++ Project that Apply the OOP concept of separations between the specifications (Book.h), implementations (Book.cpp) and Client (main.cpp). The Class Book that manages the books should include the attributes: ISBN, category, title, author, price and pageCount. Write getters and setters methods for each attribute. The class should include two different constructors, one with ISBN and one with title and author. Add a method to input a new book details, a method to purchase and calculate total cost, a method equals to check if two books are the same, a method to makeCopy and to getCopy of a book. Your Client file should test all the methods with appropriate data of your choice.
Screenshot of the code:








Sample Output:

Code to copy:
//Book.h:
//Include required header files.
#ifndef BOOK_H
#define BOOK_H
#include <iostream>
//Use the standard naming convention.
using namespace std;
//Define class Book.
class Book
{
//Declare required private member variable.
private:
string isbn;
string category;
string title;
string author;
float price;
int pageCount;
//Declare required constructor, getters and setters,
//functions.
public:
Book();
Book(string book_isbn);
Book(string book_title, string book_author);
string getISBN();
string getCategory();
string getTitle();
string getAuthor();
float getPrice();
int getPageCount();
void setISBN(string book_isbn);
void setCategory(string book_category);
void setTitle(string book_title);
void setAuthor(string book_author);
void setPrice(float book_price);
void setPageCount(int book_page_count);
void getNewBookDetails();
float calculateTotalCost(Book books[],
int num_books);
bool equalBooks(const Book &temp);
void makeCopy(const Book &book);
Book& getCopy(const Book &book);
};
#endif
//Book.cpp:
//Include book.h file.
#include "Book.h"
//Define default constructor.
Book::Book()
{
isbn = "";
category = "";
title = "";
author = "";
price = 0.0;
pageCount = 0;
}
//Define parameterized constructors.
Book::Book(string book_isbn)
{
this->isbn = book_isbn;
}
Book::Book(string book_title, string book_author)
{
this->title = book_title;
this->author = book_author;
}
//Define getter functions.
string Book::getISBN()
{
return this->isbn;
}
string Book::getCategory()
{
return this->category;
}
string Book::getTitle()
{
return this->title;
}
string Book::getAuthor()
{
return author;
}
float Book::getPrice()
{
return this->price;
}
int Book::getPageCount()
{
return this->pageCount;
}
//Define setter functions.
void Book::setISBN(string book_isbn)
{
this->isbn = book_isbn;
}
void Book::setCategory(string book_category)
{
this->category = book_category;
}
void Book::setTitle(string book_title)
{
this->title = book_title;
}
void Book::setAuthor(string book_author)
{
this->author = book_author;
}
void Book::setPrice(float book_price)
{
this->price = book_price;
}
void Book::setPageCount(int book_page_count)
{
this->pageCount = book_page_count;
}
//Define the function getNewBookDetails() to get the
//details of a new book.
void Book::getNewBookDetails()
{
cout << "Enter the ISBN number of book: ";
cin.ignore();
getline(cin, isbn);
cout << "Enter book category: ";
cin.ignore();
getline(cin, category);
cout << "Enter book title: ";
cin.ignore();
getline(cin, title);
cout << "Enter book author: ";
cin.ignore();
getline(cin, author);
cout << "Enter book price: ";
cin >> price;
cout << "Enter number of pages of the book: ";
cin >> pageCount;
}
//Define the function calculateTotalCost() to get the
//cost of all books in the array.
float Book::calculateTotalCost(Book books[],
int num_books)
{
float total_cost = 0;
for(int i = 0; i < num_books; i++)
{
total_cost = total_cost + books[i].getPrice();
}
return total_cost;
}
//Define the function equalBooks() which checks whether
//the given book is equal to the current book.
bool Book::equalBooks(const Book &temp)
{
if (author == temp.author && isbn == temp.isbn
&& category == temp.category && title == temp.title
&& price == temp.price && pageCount == temp.pageCount)
{
return true;
}
return false;
}
//Define the function makeCopy() to make an copy of
//given book object.
void Book::makeCopy(const Book &book)
{
author = book.author;
isbn = book.isbn;
title = book.title;
category = book.category;
price = book.price;
pageCount = book.pageCount;
}
//Define a function getCopy() to get the copy of given
//book object.
Book& Book::getCopy(const Book &book)
{
Book b;
b.title = book.title;
b.author = book.author;
b.isbn = book.isbn;
b.category = book.category;
b.price = book.price;
b.pageCount = book.pageCount;
return b;
}
//main.cpp:
//Include required file.
#include"Book.h"
//Define the function isBookDuplicate().
bool isBookDuplicate(Book arr_book[], int num_books,
Book book_compare)
{
//Declare and initialize required variable.
int isFound = -1;
//Traverse the given array.
for (int i = 0; i < num_books; i++)
{
//If current bool is matched with the given book,
//then increment the value of the variable isFound
//by 1.
if (arr_book[i].equalBooks(book_compare))
{
isFound++;
}
}
//If the value of the variable isFound is 0, then
//return false.
if (isFound == 0)
{
return false;
}
//Otherwise, display an appropriate message and
//return true.
cout << "\nDuplicate book found!!\n\n";
return true;
}
//Start the execution of main() method.
int main()
{
//Create an array of Book class objects and a Book
//class object.
Book temp;
Book book_arr[100];
//Declare required variables.
int num_books = 0;
char option;
//Start a while loop.
while(true)
{
//Prompt the user to enter details for current
//book by calling the function
//getNewBookDetails().
cout << "\nFor book " << num_books + 1 << ": \n";
book_arr[num_books].getNewBookDetails();
//Check if the current book is duplicate by calling
//the function isBookDuplicate().
if (!isBookDuplicate(book_arr, num_books + 1,
book_arr[num_books]))
{
//If not, then increment the value of variable
//num_books by 1.
num_books++;
}
//Prompt the user if they want to continue
//entering details for books.
cout << "Enter y to continue: ";
cin >> option;
//If the response is neither y nor Y, then break
//the loop.
if (option != 'y' && option != 'Y')
break;
//Clear the buffer.
cin.ignore();
}
//Traverse the array of Book class objects using a
//for loop.
for (int i = 0; i < num_books; i++)
{
//Display details of each book in the array.
cout << "\n\tBook " << i + 1 << " details: \n";
cout << "ISBN number: " << book_arr[i].getISBN();
cout << endl;
cout << "Book category: ";
cout << book_arr[i].getCategory() << endl;
cout << "Book title: " << book_arr[i].getTitle();
cout << endl;
cout << "Book author: " << book_arr[i].getAuthor();
cout << endl;
cout << "Book price: $" << book_arr[i].getPrice();
cout << endl;
cout << "Number of pages in book: ";
cout << book_arr[i].getPageCount() << endl;
}
//Display the total cost of all the books in the
//array by calling the function
//calculateTotalCost().
cout << "\nTotal cost of all books is: $";
cout << temp.calculateTotalCost(book_arr, num_books);
cout << endl;
}
Develop a C++ Project that Apply the OOP concept of separations between the specifications (Book.h), implementations...
C++
In this homework, you will implement a single linked list to store a list of computer science textbooks. Every book has a title, author, and an ISBN number. You will create 2 classes: Textbook and Library. Textbook class should have all above attributes and also a "next" pointer. Textbook Туре String String String Attribute title author ISBN Textbook* next Library class should have a head node as an attribute to keep the list of the books. Also, following member...
Create a Python file (book.py) that has a class named Book. Book class has four attributes, title (string), author(string), isbn(string), and year(int). Title - the name of the book. Author - the name of the persons who wrote the book. ISBN - is a unique 13 digit commercial book identifier. Year - the year the title was printed. Your class should have the following methods: (1) __init__(self, title, author, isbn, year): This method called when an object (book) is created...
Create a Python file (book.py) that has a class named Book. Book class has four attributes, title (string), author(string), isbn(string), and year(int). Title - the name of the book. Author - the name of the persons who wrote the book. ISBN - is a unique 13 digit commercial book identifier. Year - the year the title was printed. Your class should have the following methods: (1) __init__(self, title, author, isbn, year): This method called when an object (book) is created...
You need to program a simple book library system. There are three java classes Book.java // book object class Library.java //library class A2.java //for testing The Book.java class represents book objects which contain the following fields title: a string which represents the book title. author: a string to hold the book author name year: book publication year isbn: a string of 10 numeric numbers. The book class will have also 3 constructors. -The default no argument constructor - A constructor...
C++ project we need to create a class for Book and Warehouse
using Book.h and Warehouse.h header files given. Then make a main
program using Book and Warehouse to read data from book.dat and
have functions to list and find book by isbn
Objectives: Class Association and operator overloading This project is a continuation from Project 1. The program should accept the same input data file and support the same list and find operations. You will change the implementation of...
Please use netBeans Exercise 4:A librarian needs to keep track of the books he has in his Library.1. Create a class Book that has the following attributes: ISBN, Title, Author, Subject, and Price. Choose anappropriate type for each attribute.2. Add a static member BookCount to the class Book and initialize it to zero.3. Add a default constructor for the class Book. Increment the BookCount static member variable and an initialization constructor for the class Book. Increment the BookCount in all constructors.4....
PYTHON 3.6 Overview In this assignment we implement a class called TripleString. It consists of a few instance attribute and a few instance methods to support those attributes. In the next assignment, the TripleString class will help us create a more involved application. Before we do that though, we have to thoroughly test our TripleString implementation. Specifications The class TripleString will contain symbolic constants, instance attributes, and instance methods. ▶ Class symbolic constants This class has 3 symbolic constants, which...
Modify the booklist program (from the lecture notes) by adding delet and insert operations into the BookList class. The insert method should be based on a compareTo() method in the Book class that determines if one book title comes before another alphabetically. The insert method will maintain the BookList in alphabetical order. Exercise various insertion and deletion operations, using the code below for your main program: //lib.cpp #include “pch.h” #include using namespace std; #include "BookList.h" int main(int argc, char* argv[])...
Using C++ Skills Required Create and use classes Exception Handling, Read and write files, work vectors. Create Functions, include headers and other files, Loops(while, for), conditional(if, switch), datatypes, etc. Assignment You work at the computer science library, and your boss just bought a bunch of new books for the library! All of the new books need to be cataloged and sorted back on the shelf. You don’t need to keep track of which customer has the book or not, just whether...
Please provide original Answer, I can not turn in the same as my classmate. thanks In this homework, you will implement a single linked list to store a list of computer science textbooks. Every book has a title, author, and an ISBN number. You will create 2 classes: Textbook and Library. Textbook class should have all above attributes and also a “next” pointer. Textbook Type Attribute String title String author String ISBN Textbook* next Textbook Type Attribute String title String...