1. Refactor your bookType ADT that you created in Module 1B. You will need to update the implementation of your ADT by: Making the authors attribute a dynamic array and ensuring any affected code is updated to handle the new type. Adding a destructor 2. Be sure to avoid multiple inclusion of your header file (.h file) by adding the appropriate preprocessor commands in the header file itself. Example:  #ifndef H_test #define H_test //Your interface file code goes here #endif   moudule 1B code #include #include using namespace std;   class bookType { private:     string title;     string authors[4];     string publisher;     string ISBN;     double price;     int numCopies;     int numAuthors;   public:     // constructors     bookType() {         title = "";         authors[0] = "";         authors[1] = "";         authors[2] = "";         authors[3] = "";         publisher = "";         ISBN = "";         price = 0.0;         numCopies = 0;         numAuthors = 0;     }       bookType(string t, string a[], int na, string p, string i, double pr, int nc) {         title = t;         numAuthors = na;         for (int j = 0; j < na; j++)             authors[j] = a[j];         publisher = p;         ISBN = i;         price = pr;         numCopies = nc;     }       // accessors     string getTitle() {         return title;     }       string getAuthor(int index) {         return authors[index];     }       string getPublisher() {         return publisher;     }       string getISBN() {         return ISBN;     }       double getPrice() {         return price;     }       int getNumCopies() {         return numCopies;     }       int getNumAuthors() {         return numAuthors;     }       // mutators     void setTitle(string t) {         title = t;     }       void setAuthor(int index, string a) {         authors[index] = a;     }       void setPublisher(string p) {         publisher = p;     }       void setISBN(string i) {         ISBN = i;     }       void setPrice(double pr) {         price = pr;     }       void setNumCopies(int nc) {         numCopies = nc;     }       void setNumAuthors(int na) {         numAuthors = na;     }       // other functions     bool isTitle(string t) {         return (title == t);     }       bool isISBN(string i) {         return (ISBN == i);     }       void updateNumCopies(int n) {         numCopies += n;     }       void printInfo() {         cout << "Title: " << title << endl;         cout << "Authors: ";         for (int j = 0; j < numAuthors; j++)             cout << authors[j] << ", ";         cout << endl;         cout << "Publisher: " << publisher << endl;         cout << "ISBN: " << ISBN << endl;         cout << "Price: $" << price << endl;         cout << "Number of Copies: " << numCopies << endl;     }       ~bookType() {         // destructor     } };   #ifndef H_BOOKTYPE #define H_BOOKTYPE   #endif

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

1. Refactor your bookType ADT that you created in Module 1B. You will need to update the implementation of your ADT by:

  • Making the authors attribute a dynamic array and ensuring any affected code is updated to handle the new type.
  • Adding a destructor

2. Be sure to avoid multiple inclusion of your header file (.h file) by adding the appropriate preprocessor commands in the header file itself. Example: 

#ifndef H_test
#define H_test
//Your interface file code goes here
#endif

 

moudule 1B code

#include <iostream>

#include <string>

using namespace std;

 

class bookType {

private:

    string title;

    string authors[4];

    string publisher;

    string ISBN;

    double price;

    int numCopies;

    int numAuthors;

 

public:

    // constructors

    bookType() {

        title = "";

        authors[0] = "";

        authors[1] = "";

        authors[2] = "";

        authors[3] = "";

        publisher = "";

        ISBN = "";

        price = 0.0;

        numCopies = 0;

        numAuthors = 0;

    }

 

    bookType(string t, string a[], int na, string p, string i, double pr, int nc) {

        title = t;

        numAuthors = na;

        for (int j = 0; j < na; j++)

            authors[j] = a[j];

        publisher = p;

        ISBN = i;

        price = pr;

        numCopies = nc;

    }

 

    // accessors

    string getTitle() {

        return title;

    }

 

    string getAuthor(int index) {

        return authors[index];

    }

 

    string getPublisher() {

        return publisher;

    }

 

    string getISBN() {

        return ISBN;

    }

 

    double getPrice() {

        return price;

    }

 

    int getNumCopies() {

        return numCopies;

    }

 

    int getNumAuthors() {

        return numAuthors;

    }

 

    // mutators

    void setTitle(string t) {

        title = t;

    }

 

    void setAuthor(int index, string a) {

        authors[index] = a;

    }

 

    void setPublisher(string p) {

        publisher = p;

    }

 

    void setISBN(string i) {

        ISBN = i;

    }

 

    void setPrice(double pr) {

        price = pr;

    }

 

    void setNumCopies(int nc) {

        numCopies = nc;

    }

 

    void setNumAuthors(int na) {

        numAuthors = na;

    }

 

    // other functions

    bool isTitle(string t) {

        return (title == t);

    }

 

    bool isISBN(string i) {

        return (ISBN == i);

    }

 

    void updateNumCopies(int n) {

        numCopies += n;

    }

 

    void printInfo() {

        cout << "Title: " << title << endl;

        cout << "Authors: ";

        for (int j = 0; j < numAuthors; j++)

            cout << authors[j] << ", ";

        cout << endl;

        cout << "Publisher: " << publisher << endl;

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

        cout << "Price: $" << price << endl;

        cout << "Number of Copies: " << numCopies << endl;

    }

 

    ~bookType() {

        // destructor

    }

};

 

#ifndef H_BOOKTYPE

#define H_BOOKTYPE

 

#endif

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education