Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Part I – Build a Book Class Build a Book class that has the following properties

ID: 3693084 • Letter: P

Question

Part I – Build a Book Class Build a Book class that has the following properties: isbn, name, author, publisher, price and number of pages. Create the class in a header file. Your class should have 2 constructors, set and get functions as well as a display function. You may want to build a simple program with main to test out this Book class. Create one object, fill it with data and print out that data.

Part II – Build a Program to Add new Books to a File of Books Using the book class we built in Part I, create a program that when run will ask a user to input all pieces of data for a book, the program will then put this data into the Book object. Lastly, the program will store the data for this book in a file called “Books.txt”. Use a loop to ask the user if they want to enter another book or not.

Part III – Build a Program to Display all the Books in a File Using the book class we built in Part I, create another program that when run, will display all the books that are stored in the File “Books.txt”.

Explanation / Answer

Part 1
=====
#include <iostream>
#include <string>

using namespace std;
class BookType{
private:
string Title;
   string Authors[4];
string publisher;
int ISBN;
double price;
int NumOfPages;
int AotherMember;
public:
void setTitle(string t);
string getTitle();
void showTitle();
void setAuthors(string A[4]);
string getAuthors();
void showAuthors();
void setpublisher(string p);
string getpublisher();
void showpublisher();
void setISBN(int I);
int getISBN();
void showISBN();
void setprice(double r);
double getprice();
void showprice();
void setNumOfPages(int N);
int getNumOfPages();
void showNumOfPages();
void setAotherMember( int M);
   int getAotherMember();
void showAotherMember();

BookType(string t="",string A[4]=("","","",""),string p="",int I=0, double r=0, int N=0, int M=0);
~BookType();
};
void BookType::setTitle(string t){
Title=t;
}
string BookType::getTitle(){
return Title;
}
void BookType::showTitle(){
cout<<"Title"<<Title<<endl;
}
void BookType::setAuthors(string A[4]){
for(int i=0;i<4;i++)
Authors=A[i];
}
string BookType::getAuthors(){
return Authors;
}
void BookType::showAuthors(){
cout<<"Authors "<<Authors<<endl;
}
void BookType::setpublisher(string p){
publisher=p;
}
string BookType::getpublisher(){
return publisher;
}
void BookType::showpublisher(){
cout<<"publisher"<<publisher<<endl;
}
void BookType::setISBN(int I){
ISBN=I;
}
int BookType::getISBN(){
return ISBN;
}
void BookType::showISBN(){
cout<<"ISBN"<<ISBN<<endl;
}
void BookType::setprice(double r){
price=r;
}
double BookType::getprice(){
return price;
}
void BookType::showprice(){
cout<<"price"<<price<<endl;
}
void BookType::setNumOfPages(int N){
NumOfPages=N;
}
int BookType::getNumOfPages(){
return NumOfPages;
}
void BookType::showNumOfPages(){
cout<<"NumOfPages"<<NumOfPages<<endl;
}
void BookType::setAotherMember(int M){
AotherMember=M;
}
int BookType::getAotherMember(){
return AotherMember;
}
void BookType::showAotherMember(){
cout<<"AotherMember"<<AotherMember<<endl;
}
BookType::BookType(string t,string A[4],string p, int I, double r, int N, int M){
Title=t;
Authors=A[4];
publisher=p;
ISBN=I;
price=r;
NumOfPages=N;
  
   AnotherMember=M;
}
BookType::~BookType(){
cout<<"**************"<<endl;
}
int main(){
BookType BOOK;
BookType Book1();
   //Set using constructor
BookType Book2("Sweet",("lil,lool,lal,ln"),"ssss",2928830847,8,300,2);
  
   //Set method
Book1.setTitle("Sweet");
Book1.setAuthors("lil,lool,lal,ln");
Book1.setpublisher("ssss");
Book1.setISBN("2928830847");
Book1.setprice("8");
Book1.setNumOfPages("300");
Book1.setAnotherMember("2");
//Display
Book1.showTitle();
Book1.showAuthors();
Book1.showpublisher();
Book1.showISBN();
Book1.showprice();
Book1.showNumOfPages();
Book1.showAnotherMember();

return 0;
}

Part 1
=====

#include <iostream>

#include <string>

using namespace std;

class BookType{

private:

string Title;
   string Authors[4];
string publisher;
int ISBN;
double price;
int NumOfPages;
int AotherMember;

public:

void setTitle(string t);
string getTitle();
void showTitle();
void setAuthors(string A[4]);
string getAuthors();
void showAuthors();
void setpublisher(string p);
string getpublisher();
void showpublisher();
void setISBN(int I);
int getISBN();
void showISBN();
void setprice(double r);
double getprice();
void showprice();
void setNumOfPages(int N);
int getNumOfPages();
void showNumOfPages();
void setAotherMember( int M);
   int getAotherMember();
void showAotherMember();

BookType(string t="",string A[4]=("","","",""),string p="",int I=0, double r=0, int N=0, int M=0);
~BookType();

};
void BookType::setTitle(string t){

Title=t;
}

string BookType::getTitle(){

return Title;
}

void BookType::showTitle(){

cout<<"Title"<<Title<<endl;
}

void BookType::setAuthors(string A[4]){

for(int i=0;i<4;i++)
Authors=A[i];

}

string BookType::getAuthors(){

return Authors;
}

void BookType::showAuthors(){

cout<<"Authors "<<Authors<<endl;

}

void BookType::setpublisher(string p){

publisher=p;
}

string BookType::getpublisher(){

return publisher;
}

void BookType::showpublisher(){

cout<<"publisher"<<publisher<<endl;
}

void BookType::setISBN(int I){
ISBN=I;

}

int BookType::getISBN(){
return ISBN;
}

void BookType::showISBN(){

cout<<"ISBN"<<ISBN<<endl;

}

void BookType::setprice(double r){

price=r;
}

double BookType::getprice(){

return price;
}

void BookType::showprice(){

cout<<"price"<<price<<endl;
}

void BookType::setNumOfPages(int N){

NumOfPages=N;
}
int BookType::getNumOfPages(){

return NumOfPages;
}

void BookType::showNumOfPages(){

cout<<"NumOfPages"<<NumOfPages<<endl;

}

void BookType::setAotherMember(int M){

AotherMember=M;
}

int BookType::getAotherMember(){

return AotherMember;

}

void BookType::showAotherMember(){

cout<<"AotherMember"<<AotherMember<<endl;
}

BookType::BookType(string t,string A[4],string p, int I, double r, int N, int M){

Title=t;

Authors=A[4];

publisher=p;

ISBN=I;

price=r;

NumOfPages=N;
  
   AnotherMember=M;

}

BookType::~BookType(){

cout<<"**************"<<endl;

}

int main(){

BookType BOOK;

BookType Book1();

   //Set using constructor
BookType Book2("Sweet",("lil,lool,lal,ln"),"ssss",2928830847,8,300,2);

  
   //Set method
Book1.setTitle("Sweet");

Book1.setAuthors("lil,lool,lal,ln");

Book1.setpublisher("ssss");

Book1.setISBN("2928830847");

Book1.setprice("8");

Book1.setNumOfPages("300");

Book1.setAnotherMember("2");

//Display
Book1.showTitle();

Book1.showAuthors();

Book1.showpublisher();

Book1.showISBN();

Book1.showprice();

Book1.showNumOfPages();

Book1.showAnotherMember();


return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote