01.11.10 - 05.09.10
Tut class created | 10 pts |
to_tut and to_english methods are class methods | 20 pts |
English to tut conversion is correct | 20 pts |
Tut to English conversion is correct | 20 pts |
Methods return characters to their blocks | 10 pts |
Test code executes correctly | 20 pts |
Total | 100 pts |
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 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?".