Spring 2015

Lab06
Tut

Due: Tuesday April 14, 2015 11:59 PM

Lab06 - Tut

Requirements

Tut class created10 pts
to_tut and to_english methods are class methods20 pts
English to tut conversion is correct20 pts
Tut to English conversion is correct20 pts
Methods return characters to their blocks10 pts
Test code executes correctly20 pts
Total100 pts

Resources

Objective

To practice working with iterators and blocks

Instructions

For this lab you will need to create a Ruby class called Tut. This class should contain two class methods, one called to_tut and the other called to_english.

The to_tut method should accept an english string as an argument to the method and then should pass each of the characters of that string converted to tut (so it may actually be more than one character passed) to a block associated with the method.

The to_english method should receive a string of tut as an argument and then should pass each of the characters of that string converted to english to a block associated with the method.

When your Tut class is working properly you should be able to execute the following test code and have it produce the specified output:

Tut.to_tut( "Wow! Look at this get converted to Tut!" ) { |c| print c }
# should outout : Wutowut! Lutookut atut tuthutisut gutetut cutonutvuteruttutedut tuto Tututut!'

tut_string = ""
Tut.to_tut( "I'm in tut but I want to be in english." ) { |c| tut_string += c }
puts tut_string
# should output : I'mut inut tututut bututut I wutanuttut tuto bute inut enutgutlutisuthut.

Tut.to_english( tut_string ) { |c| print c }
# should output : I'm in tut but I want to be in english.

The Language of Tut

The tut language is a simple encoded language where words are spelled out and the letters "ut" are placed after every constant, vowels are left as they are. So the word "Hello", in tut become "Hutelutluto" The word "Goodbye" becomes "Gutoodutbutyute". The sentence "How are you today?", becomes "Hutowut arute yutou tutodutayut?".