Application Kata „Wordwrap“
Write an application that rearranges a text so that lines are wrapped at a given column width.
The following illustration shows how the application may look like.
The user will enter the text into a textbox. Furthermore the user gives the number of characters per line. The example shows 25 characters as the new line length. Clicking the Wrap button wraps the text. The result is shown in the lower textbox.
Variation #1
The program can be written as a command line application.
Filename and width oft he wrapped text are given as command line parameters:
C:> wrap hansel-and-gretel.txt 25
Hansel and Gretel are
young children whose
father is a woodcutter.
When a great famine
settles over the land,
the woodcutter's abusive
second wife decides to
take the children into
the woods...
Integrate a hyphenation library like NHunspell [1] to split words into syllables.
Resources
[1] http://nhunspell.sourceforge.net/
“Ich bin der Gründer von Majer Consulting. In der Welt der SAP bin ich seit 1998 unterwegs, habe in dieser Zeit zahlreiche Projekte als Entwickler, Architekt oder Coach unterstützt und eine große Leidenschaft für Software-Engineering, Software-Test und agilen Entwicklungsmethoden wie TDD entwickelt. Wenn ich nicht im Kundeneinsatz bin oder Seminare halte, spreche ich auf Konferenzen oder schreibe an meinem nächsten Buch.”