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

I need help with this project: Your goal is to use Object Oriented techniques to

ID: 3771439 • Letter: I

Question

I need help with this project: Your goal is to use Object Oriented techniques to read the complete works of Shakespeare from a file, and allow for word searches. A complete version of all works of Shakespeare in a single file is available here: Shakespeare.txt. Your program must do at least the following: Read in the entire file of Shakespeare books, and parse it into Books and Paragraphs, where Books is object the contains an entire book (definition below), and Paragraph is an object representation of a paragraph (also below). Thus there will be an array of Books, and each book will be a title plus an array of paragraphs. Show the user a list of the book titles, alone with the number of paragraphs found in each. Ask the user for a word to search, and show the users how many paragraphs in each book has a match for this word. Repeat the above step until the user is done.

The class definitions are provided below

The program should have a vector of book.

Explanation / Answer

#include <iostream>
   #include<vector>
   using namespace std;
     
   class paragraph {
   string name;
   vector<string> paragraphs;
   public:
   void setName (string name) //{ here is ->name = name; }
   {
   for ( int i = 0; i < paragraphs.size(); ++i)
   {
   paragraphs.push_back(name);
   }
   }
     
   void getName() // { name is return; }
   {
   for ( int i = 0; i < paragraphs.size(); ++i)
   {
   string x = paragraph.at(i);
     
   cout << x << endl;
}
   }
   };
     
   int main() {
     
   paragraph p;
   string name;
   int size;
     
     
   cout << "How many paragraph to create? ";
   cin >> size;
     
   for (int i = 0; i < size; i++) {
   cout << "paragraph #" << i+1<< " : Enter name = ";
   cin >> name;
   p.setName (name);
   }
     

   p.getName();

   return 0;
   }