Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ We now have a list of books (in the form of an array of Book objects) and a list of users and their ratings

C++

We now have a list of books (in the form of an array of Book objects) and a list of users and their ratings (in the form of an array of User objects).

We now update the getRating function from last week to use these arrays of User and Book objects , to search for a particular users rating for a particular book title. Write a function that, given a users name and a books title, returns the rating that the user gave for that book.

  • Your function MUST be named getRating.

  • Your function should take 6 input arguments in the following order:

    • string: username

    • string: title of the book

    • Array of User objects: users

    • Array of Book objects: books

    • int: number of users currently stored in the users array

    • int: number of books currently stored the books array

  • The username and book title search should be case insensitive. Ben, ben and BEN are one and the same user.

  • If both the user name and the book title are found in the arrays, then the function should return the users rating value for that book title.

  • The function should return the following values depending on cases:

    • Return the rating value if both user and title are found

    • Return -3 if the user or the title are not found

here is the .h file

image text in transcribed

#ifndef BOOK_H #define BOOK_H #include  using namespace std; class Book { private: string title; string author; public: Book(); Book(string title, string author); string getTitle() const; void setTitle(string title); string getAuthor() const; void setAuthor(string author); };

image text in transcribed

#include "Book.h" Book::Book() {} Book::Book(string title, string author) : title(title), author(author) {} string Book::getTitle() const { return title; } void Book::setTitle(string title) { this->title = title; } string Book::getAuthor() const { return author; } void Book::setAuthor(string author) { this->author = author; } 

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

More Books

Students also viewed these Databases questions