Final Project - ShakespeareDue: May 3, 4:00pm(No late submissions allowed)Moodle Link![]() | ![]() |
Requirement | Grading Comments | Points | Score |
---|---|---|---|
Easy to use user interface | 5 | ||
Functional decomposition: Program should be factored into functions to reduce complexity. "main()" should not be one be function, but should be divided into supporting functions (Like "readBooks(bookVector, filestream)". |
10 | ||
Class Design: Classes have appropriate methods added as needed, new classes well designed | 10 | ||
Class Implementation : Logic is correctly implements in the each class methods | 20 | ||
C++ code includes comments, with project information at top, pre and post conditions for each functions and other comments as needed. |
5 | ||
The C++ code has good formatting, indentation, and organization. | 5 | ||
Good variable and function names, appropriate use of constants rather then literal numbers. | 5 | ||
Runs: Run of game works correct (Run for given test cases) | 40 | ||
Total | 100 |
Feature | Credit |
1. Highlight the matching words. | 1% |
4. Add support more two or more adjacent words, such as "Lady MacBeth " or "to be or not to be". | 1% |
Total | 2% |
class Book { private: string title; vector<string> lines; string searchWord; int searchPos; vector<string> getWords(string line); string removeSpecials(string str); int countMatchesInLine(string line, string word); public: Book(); void setTitle(string aTitle); // Set the title of this book string getTitle(); // Get the title int countMatches(string word); // Return the number of time word appears in a Book int size(); // Number of lines in book; void addLine(string line); // add a line to the book; void clear(); // Clear the contents and title of book void startSearch(string word); // Start a search for getNextMatch string getNextMatch(); // retrieve the next line that matches from the findWord // Return empty string when done bool searchDone(); // Return true if search is complete };
vector<string> Book::getWords(string line) { istringstream iss(line); vector<string> words; string s; do { iss >> s; if (s.length() > 0 && s != " ") { words.push_back(s); //cout << s << " "; } s = ""; } while (iss); return words; } string Book::removeSpecials(string str) { int i = 0, len = str.length(); while (i < len) { char c = str[i]; if (((c >= '0')&&(c <= '9')) || ((c >= 'A')&&(c <= 'Z')) || ((c >= 'a')&&(c <= 'z')) || c == '\'' || c == ' ') { if ((c >= 'A')&&(c <= 'Z')) str[i] += 32; //Assuming dictionary contains small letters only. ++i; } else { str.erase(i, 1); --len; } } return str; }
Number of books: 38 1. THE SONNETS 2. ALLS WELL THAT ENDS WELL 3. THE TRAGEDY OF ANTONY AND CLEOPATRA 4. AS YOU LIKE IT 5. THE COMEDY OF ERRORS 6. THE TRAGEDY OF CORIOLANUS 7. CYMBELINE 8. THE TRAGEDY OF HAMLET, PRINCE OF DENMARK 9. THE FIRST PART OF KING HENRY THE FOURTH 10. SECOND PART OF KING HENRY IV 11. THE LIFE OF KING HENRY THE FIFTH 12. THE FIRST PART OF HENRY THE SIXTH 13. THE SECOND PART OF KING HENRY THE SIXTH 14. THE THIRD PART OF KING HENRY THE SIXTH 15. KING HENRY THE EIGHTH 16. KING JOHN 17. THE TRAGEDY OF JULIUS CAESAR 18. THE TRAGEDY OF KING LEAR 19. LOVE'S LABOUR'S LOST 20. THE TRAGEDY OF MACBETH 21. MEASURE FOR MEASURE 22. THE MERCHANT OF VENICE 23. THE MERRY WIVES OF WINDSOR 24. A MIDSUMMER NIGHT'S DREAM 25. MUCH ADO ABOUT NOTHING 26. THE TRAGEDY OF OTHELLO, MOOR OF VENICE 27. KING RICHARD THE SECOND 28. KING RICHARD III 29. THE TRAGEDY OF ROMEO AND JULIET 30. THE TAMING OF THE SHREW 31. THE TEMPEST 32. THE LIFE OF TIMON OF ATHENS 33. THE TRAGEDY OF TITUS ANDRONICUS 34. THE HISTORY OF TROILUS AND CRESSIDA 35. TWELFTH NIGHT; OR, WHAT YOU WILL 36. THE TWO GENTLEMEN OF VERONA 37. THE WINTER'S TALE 38. A LOVER'S COMPLAINT Enter a word to search for (* to end):rascal 1. THE SONNETS Matches: 0 2. ALLS WELL THAT ENDS WELL Matches: 1 3. THE TRAGEDY OF ANTONY AND CLEOPATRA Matches: 0 4. AS YOU LIKE IT Matches: 1 5. THE COMEDY OF ERRORS Matches: 0 6. THE TRAGEDY OF CORIOLANUS Matches: 1 7. CYMBELINE Matches: 3 8. THE TRAGEDY OF HAMLET, PRINCE OF DENMARK Matches: 1 9. THE FIRST PART OF KING HENRY THE FOURTH Matches: 9 10. SECOND PART OF KING HENRY IV Matches: 9 11. THE LIFE OF KING HENRY THE FIFTH Matches: 3 12. THE FIRST PART OF HENRY THE SIXTH Matches: 0 13. THE SECOND PART OF KING HENRY THE SIXTH Matches: 3 14. THE THIRD PART OF KING HENRY THE SIXTH Matches: 0 15. KING HENRY THE EIGHTH Matches: 0 16. KING JOHN Matches: 0 17. THE TRAGEDY OF JULIUS CAESAR Matches: 1 18. THE TRAGEDY OF KING LEAR Matches: 6 19. LOVE'S LABOUR'S LOST Matches: 0 20. THE TRAGEDY OF MACBETH Matches: 0 21. MEASURE FOR MEASURE Matches: 3 22. THE MERCHANT OF VENICE Matches: 0 23. THE MERRY WIVES OF WINDSOR Matches: 2 24. A MIDSUMMER NIGHT'S DREAM Matches: 0 25. MUCH ADO ABOUT NOTHING Matches: 0 26. THE TRAGEDY OF OTHELLO, MOOR OF VENICE Matches: 1 27. KING RICHARD THE SECOND Matches: 0 28. KING RICHARD III Matches: 0 29. THE TRAGEDY OF ROMEO AND JULIET Matches: 0 30. THE TAMING OF THE SHREW Matches: 4 31. THE TEMPEST Matches: 0 32. THE LIFE OF TIMON OF ATHENS Matches: 3 33. THE TRAGEDY OF TITUS ANDRONICUS Matches: 0 34. THE HISTORY OF TROILUS AND CRESSIDA Matches: 2 35. TWELFTH NIGHT; OR, WHAT YOU WILL Matches: 2 36. THE TWO GENTLEMEN OF VERONA Matches: 0 37. THE WINTER'S TALE Matches: 1 38. A LOVER'S COMPLAINT Matches: 0 To display the lines containing rascal enter the number of the book, or 0 to search for another word: 9 Prince. I comes forward I Peace, ye fat-kidney'd rascal! What a Fal. I am accurs'd to rob in that thief's company. The rascal hath with the rogue's company. If the rascal have not given me action. Zounds, an I were now by this rascal, I could brain him rascal is this! an infidel! Ha! you shall see now, in very Fal. Well, that rascal hath good metal in him; he will not run. Prince. Why, what a rascal art thou then, to praise him so for Prince. This oily rascal is known as well as Paul's. Go call him whoreson, impudent, emboss'd rascal, if there were anything in To display the lines containing rascal enter the number of the book, or 0 to search for another word: 30 I bade the rascal knock upon your gate, While she did call me rascal fiddler And bring along these rascal knaves with thee? What dogs are these? Where is the rascal cook? To display the lines containing rascal enter the number of the book, or 0 to search for another word: 29 To display the lines containing rascal enter the number of the book, or 0 to search for another word: 0 Enter a word to search for (* to end):brain 1. THE SONNETS Matches: 5 2. ALLS WELL THAT ENDS WELL Matches: 0 3. THE TRAGEDY OF ANTONY AND CLEOPATRA Matches: 5 4. AS YOU LIKE IT Matches: 3 5. THE COMEDY OF ERRORS Matches: 0 6. THE TRAGEDY OF CORIOLANUS Matches: 3 7. CYMBELINE Matches: 9 8. THE TRAGEDY OF HAMLET, PRINCE OF DENMARK Matches: 6 9. THE FIRST PART OF KING HENRY THE FOURTH Matches: 1 10. SECOND PART OF KING HENRY IV Matches: 4 11. THE LIFE OF KING HENRY THE FIFTH Matches: 1 12. THE FIRST PART OF HENRY THE SIXTH Matches: 0 13. THE SECOND PART OF KING HENRY THE SIXTH Matches: 2 14. THE THIRD PART OF KING HENRY THE SIXTH Matches: 0 15. KING HENRY THE EIGHTH Matches: 2 16. KING JOHN Matches: 1 17. THE TRAGEDY OF JULIUS CAESAR Matches: 0 18. THE TRAGEDY OF KING LEAR Matches: 2 19. LOVE'S LABOUR'S LOST Matches: 4 20. THE TRAGEDY OF MACBETH Matches: 4 21. MEASURE FOR MEASURE Matches: 0 22. THE MERCHANT OF VENICE Matches: 1 23. THE MERRY WIVES OF WINDSOR Matches: 2 24. A MIDSUMMER NIGHT'S DREAM Matches: 0 25. MUCH ADO ABOUT NOTHING Matches: 2 26. THE TRAGEDY OF OTHELLO, MOOR OF VENICE Matches: 2 27. KING RICHARD THE SECOND Matches: 1 28. KING RICHARD III Matches: 0 29. THE TRAGEDY OF ROMEO AND JULIET Matches: 3 30. THE TAMING OF THE SHREW Matches: 0 31. THE TEMPEST Matches: 2 32. THE LIFE OF TIMON OF ATHENS Matches: 0 33. THE TRAGEDY OF TITUS ANDRONICUS Matches: 0 34. THE HISTORY OF TROILUS AND CRESSIDA Matches: 9 35. TWELFTH NIGHT; OR, WHAT YOU WILL Matches: 3 36. THE TWO GENTLEMEN OF VERONA Matches: 0 37. THE WINTER'S TALE Matches: 2 38. A LOVER'S COMPLAINT Matches: 0 To display the lines containing brain enter the number of the book, or 0 to search for another word: 19 That hath a mint of phrases in his brain; Other slow arts entirely keep the brain; Lives not alone immured in the brain, To weed this wormwood from your fruitful brain, To display the lines containing brain enter the number of the book, or 0 to search for another word: 2 To display the lines containing brain enter the number of the book, or 0 to search for another word: 8 Without more motive, into every brain Within the book and volume of my brain, And I do think- or else this brain of mine Fie upon't! foh! About, my brain! Hum, I have heard Queen. Sleep rock thy brain, Queen. This is the very coinage of your brain. To display the lines containing brain enter the number of the book, or 0 to search for another word: 0 Enter a word to search for (* to end):*Solution
I![]() |
Attachment | History | Action | Size | Date | Who | Comment |
---|---|---|---|---|---|---|---|
![]() |
BIO_Mini-Bios_William-Shakespeare_SF_HD_768x432-16x9.jpg | r1 | manage | 71.7 K | 2016-10-01 - 21:47 | JimSkon | |
![]() |
C_-_shakespeare.png | r1 | manage | 18.8 K | 2016-11-08 - 05:43 | JimSkon | |
![]() |
ShakespeareRead.png | r2 r1 | manage | 25.3 K | 2017-11-29 - 15:31 | JimSkon | |
![]() |
Shakespeare.txt | r1 | manage | 5337.2 K | 2016-11-16 - 20:47 | JimSkon |