HOME | Overview | Syllabus | Instructor | Lectures | Laboratories | Readings | Assignments | Resources | Other Links
CS 1713 Lecture 23: A Design Problem Using Strings and Loops
October 22, 1999

In this class period we will work on a design project as a group. In doing the design, you should think first about the overall structure of the problem. Don't get hung up on particular implementation details that you don't know how to do. Define appropriate helper functions that will take care of those details and worry about how to implement them after you have the overall design.

Implement and test a class representing a sentence. A sentence is defined as an ordered sequence of words separated by single blanks. Sentences have no leading or trailing blanks and end with a period. The first word in every sentence is capitalized. The class is initialized by an arbitrary string, which should be converted to a valid sentence by removing extra blanks and invalid words. Clients (users) of the Sentence class will want to know how many words are in the sentence and the average length of the words in the sentence. Clients will also want to be able to get the n-th word in the sentence. The Sentence class provides clients with printStatistics and toString methods to facilitate display of results.

Note: A word is defined as a sequence of characters that starts with a letter and has no blanks. Words may contain hyphens, apostrophes and numbers.


Objective: Practice with design - using helpers to reduce complexity and defer details.
Last revision: October 21, 1999 at 9:30 am