Skip to main content


2 replies [Last post]
Joined: 2007-10-18

can anyone help me with my school labs

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2004-11-17

Why would anyone want to do your homework?

Joined: 2007-10-18

1. Lipograms
This lab is a modified version of the Lipograms lab described in section 10.8 of your book.
A lipogram (from Greek lipagrammatos, "missing letter") is a kind of constrained writing or word game consisting of writing paragraphs or longer works in which a particular letter or group of letters is missing, usually a common vowel, the most common in English being the letter e. A lipogram author avoiding e then only uses the 25 remaining letters of the alphabet.
An example of a lipogram omitting "e" is this version of the preceding paragraph:
A lipogram is a kind of writing with constraints that consists of full paragraphs or books in which a particular symbol, such as that fifth symbol (which is most common in writing), is missing. A lipogram author must submit to an awful handicap, allowing only consonants and A, I, O, U, and Y. This is ordinarily a quorum of six fours plus half of two.
Of course, one can't possibly be expected to write a Lipogram without (drumroll, please...) an automated Lipogram checker! Your task is to finish the LipogramAnalyzer class. This class requires a constructor that takes in a String and the two public methods described in the class' comments. An additional public method, showAllWordsWith, is completed for you. Of course, you are free to write any additional methods you feel you may need.
The method mark, which replaces every occurrence of a letter with the character '#' is easy. Have a look at the Java API page for Strings. There is a method that will do this in one step.
The method allWordsWith will be much trickier. You'll need to inspect the string, one character at a time, and look for the offending letter. When you find it, get the entire word, add a "\n", and append it to a "result" string only if it isn't already there. Return the "result" string.
A hint: How do you check to see if you've already added a word to the "result" string? Look up the method indexOf on the API page for String. There is a way to use it to see if a substring occurs on another string. (Technically, this method isn't foolproof—we'll get a "false positive" if we search for "end\n" on a string that contains "pretend\n". Don't worry; your program will not be tested with data that will cause this behavior.)
Some tests:
Construct with the String: "This is a test of the lipogram analyzer. This is only a test. Do not be alarmed."
The method call mark('e') will return:
"This is a t#st of th# lipogram analyz#r. This is only a t#st. Do not b# alarm#d."
The method call allWordsWith('e') will return:
And the method call showAllWordsWith('e') will display: