In order to understand the everyday hasstle of people that suffer from dislexia my school made us do this activity:
- replace all the (A's O's E's I's) of a certain phrase with (4's 0's 3's 1's) respectively
and we did it, but it took soooo long, would you write a bit of code that does the work for me?
e.g.:
dislexifier ->
- input : "Hey Arianna, how u doing?"
- output : "H3y 4ri4nn4, h0w u d01ng?"
ps.: try to avoid just using .replace(), it will make it more fun.
class Dislexifier
{
public static String theDislexifier(String str)
{
// TODO: Do your magic here
return str.replace("a","4").replace("A","4").replace("o","0").replace("O","0").replace("e","3").replace("E","3").replace("i","1").replace("I","1");
}
}
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import org.junit.runners.JUnit4;
// TODO: Replace examples and use TDD by writing your own tests
public class SolutionTest {
@Test
public void testDislixifier() {
assertEquals("1'm s0 hungry 1 c0uld 34t 4 b34r rn",Dislexifier.theDislexifier("I'm so hungry I could eat a bear rn"));
assertEquals("Wh4t 4r3 th000000s3???",Dislexifier.theDislexifier("What are thoooooose???"));
assertEquals("",Dislexifier.theDislexifier(""));
assertEquals("üüüü 1s just 4 f4ncy u, 4lth0ugh n0t 4s f4ncy 4s y0u",Dislexifier.theDislexifier("üüüü is just a fancy u, although not as fancy as you"));
assertEquals("щф, l1t3r4lly just g00gl3d \"russ14n l3tt3rs\", th4t sh1dd's w31rd\"",Dislexifier.theDislexifier("щф, literally just googled \"russian letters\", that shidd's weird\""));
assertEquals("Try gypsy hymns rhythm !",Dislexifier.theDislexifier("Try gypsy hymns rhythm !"));
}
}