On this page:
Our New History
Lines of Words
Lines of Text
6.10

Lab 12: Chatting with Text

Implement this lab with the Beginning Student Language. Require the HtDP2e image and universe libraries at the top of your definitions:
(require 2htdp/image)
(require 2htdp/universe)

Make sure you follow The Style we use for the {B,I,A}SL{,+} languages in this class.

Open your current ChatClient implementation from labs 6-8, 10, 11. Make sure you’ve completed these labs before you continue with this lab and save/submit your definitions. We will be extending this program in future labs.

Choose the initial Head and Hands, and get started!

Our New History

In Lab 11: Chatting with Words we changed our History data definition to a ListofMessage and worked toward handling longer messages. In this lab we’ll get our client up and running with our more interesting History.

Ex 1: Modify all of your example ChatClients to reflect the new data definition for History.

Ex 2: In a comment in your definitions window, write down a list of all functions that need to change based on our new History (it should include at least the functions create-client, draw-client, and add-message).

Hint: Without changing anything else in your program, run your old tests with your new ChatClient examples. Then write down every function that has failing tests. This is your TODO-list for updating your current implementation to account for our new data definition.

Note: If you have no examples or failing tests, you didn’t follow the design recipe up to this point and this exercise is much more difficult.

Ex 3: Redesign those functions such that they operate on the new History data definition. For the function draw-client, first get the history drawn without regard to message length.

Lines of Words

Swap Head and Hands!

Ex 5: Design a function words->string that appends the Words inside the given ListofWords into a single string with a space between each Word.

Ex 6: Create a data definition and template for a ListofListofWords.

Ex 7: Design a function lowords->string that appends the ListofWords inside the given ListofListofWords into a single string with newlines between each ListofWord and a space between each Word.

Ex 8: Design a function lowords->image that renders the given list of lists of Words into an image using text with newlines between each ListofWord and spaces between each Word.

Ex 9: Using string->words from the last lab, design a function string->lowords that, given a String s and a Natural n, returns a ListofListofWord where each ListofWord is no more than n Words long.

Ex 10: Using string->words from the last lab, design a function string->lowords/char that, given a String s and a Natural n, returns a ListofListofWord where each ListofWord is no more than n Chars long.

Lines of Text

Swap Head and Hands!

Ex 11: Create a data definition and template for a ListofImages.

Ex 12: Design a function string->loimage that, given a String s and a Natural n, returns a ListofImages where each Image is no more than n pixels wide.

Ex 13: Use the function string->loimage to wrap lines of History correctly in draw-client.