Tags: %TAGME{ tpaction="" web="SCMP118/Fall2016" tag="" }% view all tags

Lab 10

Due: Dec 10, 11:55pm


  • Turn in the code (a cpp file or ideone.com link), and the run outputs as requested below.
  • Remember to format the code as described and the book and text, and to include comments including complete commetns at the beginning of the program.


Feature %
Program correctness and completeness with respect to defination 70%
Code Format (Indenting, variable names) 10%
Code Comments 10%
Turning in the run the requested inputs below.. 10%


Shakespeare Word Search

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 preseanted here.

Your program must do at least the following:

  1. 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.
  2. Show the user a list of the book titles, alone with the number of paragraphs found in each.
  3. Ask the user for a word to search, and show the users how many paragraphs in each book has a match for this word.
  4. Repeat the above step until the user is done.

Extra credit

Since this is the lass project you will have the opportunity to explore this problem, and add extra credit toward your overall grade. Following are a list of possible options, with a percent of how much it add to your OVERALL grade. You may propose additional improvements for extra credit by emailing me with a proposal, and I will decide if it can be approved, and how much it is worth.

Some options:

  1. (1%) Add an option to show the matches from a selected book (shown in the example below.
  2. (1%) Add support fot a second author or set of works. The second file must be at least 1Mb, and you will need to format it appropriately. You will have two programs, one for Shakespeare, and onother for the new file.
  3. (2%) Add support for 5 or more authors, and start with a menu listing the options, and allowing the user to select the works, then to the other operations. This option is mutually exclusive with #2.
  4. (1%) Add support to #3 to search ALL books.
  5. (2%) Add support to #1 & #2 to search for pairs of words, not necessarily adjacent.
  6. (1%) Add support to #5 to search for words within some specified numbers of word apart.
  7. More to come ...

class paragraph {
        string text;
        void setText(string p);
        bool search(string word);
        void display();

class book {
        string title;
        vector<paragraph> paragraphs;
        void setTitle(string title);
        string getTitle();
        int search(string word);
        void add(paragraph p);
        void clear();
        int getParaCount();
        void displayMatches(string search);


Topic attachments
I Attachment History Action Size Date Who Comment
Texttxt Shakespeare.txt r1 manage 5337.2 K 2015-11-17 - 18:11 JimSkon  
Edit | Attach | Watch | Print version | History: r34 | r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r1 - 2015-11-17 - JimSkon
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback