Question: Did I define the Class and private and public elements correctly // Each element of the array is an object of that class Library.h: #include

Did I define the Class and private and public elements correctly

// Each element of the array is an object of that class

Library.h:

#include

#include

#inclue

#include

#include

#include

using namespace std;

#ifndef Library_H

#define Library_H

// create a class Library

class Library

{

// declare your data members

private:

Book books[sizeBook];

User users[sizeUser];

int numBooks = 0;

int numUsers = 0;

int sizeBook = 200;

int sizeUser = 200;

public:

//declare functions

// constructor Library that sets both numBooks and numUsers to value 0

// reads in the files, populates the arrays and returns the tot # in the array as an integer

Library();

Library(string readBooks, string readRatings);

//Print all books stored in the book array

int printAllBooks(books);

// return the # of books read by user

string getCountReadBooks() const;

//returns the average rating of specified book as a double

double calcAvgRating();

// Add the username and return True if the username is successfully added to the database, otherwise, returns False

string addUser() const;

};

Create a class Library, with separate interface and implementation, comprised of the following attributes:

Data members (private):

Book array: books

An array of Book objects

User array: users

An array of User objects

int: numBooks

Number of books in the database (library)

int: numUsers

Number of users in the database (library)

int: sizeBook

The capacity of the books array (200). Constant

int: sizeUser

The capacity of the users array (200). Constant

Member functions (public):

Default constructor

Sets both numBooks and numUsers to value 0.

readBooks(string)

Takes a string (the name of the file to be read) and populates the books array. Returns the total number of books in books array as an integer

readRatings(string)

Takes a string (the name of the file to be read) and populates the users array. Returns the total number of users in users array as an integer

printAllBooks()

Prints all books stored in books array.

getCountReadBooks(string)

Takes a string (username) and returns the number of books read by that user as an integer.

calcAvgRating(string)

Takes a string (the title of a book) and returns the average rating of the specified book as a double

addUser(string)

Takes a string (username) and returns True if the username is successfully added to the database. Otherwise, returns False.

checkOutBook(string, string, int)

Takes two strings and an integer for username, title of book, and a new rating, respectively (in this order). Returns True if the rating is successfully updated. Otherwise, returns False.

viewRatings(string)

Takes a string (username) and prints all the books a user has provided ratings for.

getRecommendations(string

) Takes a string username and prints the first 5 book recommendations from the most similar (other) user.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!