Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello. please answer this following question will upvote. I only need number 2 but if you can please answer number 3 as well would be

Hello. please answer this following question will upvote.

I only need number 2 but if you can please answer number 3 as well would be very helpful.

image text in transcribed

/ Library.h

#ifndef LIBRARY_H

#define LIBRARY_H

#include "Book.h"

#define MAX_ARR_SIZE 128

class Library{

private:

Book books[MAX_ARR_SIZE];

int numOfBooks;

public:

Library();

void addBook(Book &);

void print();

};

#endif

//end of Library.h

// Library.cpp

#include "Library.h"

#include

#include

using namespace std;

Library::Library()

{

numOfBooks=0;

}

void Library::addBook(Book &book)

{

if(numOfBooks

{

books[numOfBooks] = book;

numOfBooks++;

}else

cout

}

void Library::print()

{

if(numOfBooks == 0)

cout

else

{

cout

for(int i=0;i

books[i].print();

}

}

//end of Library.cpp

1 12 2. Create a new Array class. You will need both a header file and a source file for this class. You can refe to the course material (section 2.1) and the coding examples done in class to see what belongs in the header file and what belongs in the source file. The class will contain two data members: .a data member called elements, which is an array of Book objects .a data member called size, which is the current number of books in the array Since the book array is moving from the Library class, you will also move the constant array size definition (MAX ARR_SIZE) into the correct location. 3. Write the following functions for the Array class: .a constructor that initializes the data member(s) that require initialization . an add (Book&) function that adds the given book parameter to the back of the book array .a print () function that prints out all the books in the array to the screen Note: These functions will be identical to the ones you wrote for the Library class in Tutorial #2. 4. Modify the Library class so that it does not manipulate the book array elements directly: remove the two data members that keep track of the books, and replace them with an Array object

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Calculus Of A Single Variable

Authors: Ron Larson, Bruce H. Edwards

11th Edition

978-1337275361, 9781337275361

Students also viewed these Databases questions