diff --git a/src/main/java/io/zipcoder/Problem1.java b/src/main/java/io/zipcoder/Problem1.java index 6cd6024..633eb44 100644 --- a/src/main/java/io/zipcoder/Problem1.java +++ b/src/main/java/io/zipcoder/Problem1.java @@ -1,4 +1,43 @@ package io.zipcoder; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Scanner; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + + public class Problem1 { + +// Input = “The Farmer went to the store to get 1 dollar’s worth of fertilizer” +// Output = “The 7@rmer went to the $tore to get ! doll@r’$ worth of 7ertilizer” + +//break it down "The Farmer" to "The 7@rmer" no change for the first word +// but I need to change F to 7 and a to @ for the second word. + //where to scan in input? in unit test? + // write unit test + //key is f, value is 7, how to replace key with value? + //{ ‘f’ : ‘7’, + // ‘s’:’$’, + // ‘1’:’!’, + // ‘a’.:’@’} map? + //change the word.. substring + //toString back to a sentence + + public static void main(String[] args)throws Exception { + +// String s2 = "The Farmer went to the store to get 1 dollar’s worth of fertilizer"; +// String[] t = s2.split("(?= )"); +// for (String e : t) +// System.out.println(e); + + StringBuilder pattern = new StringBuilder(); + + + String input = "The Farmer went to the store to get 1 dollar’s worth of fertilizer"; + Matcher m = Pattern.compile(pattern.substring(1)).matcher(input); + + } + } diff --git a/src/main/java/io/zipcoder/WordParser.java b/src/main/java/io/zipcoder/WordParser.java new file mode 100644 index 0000000..9b2d93e --- /dev/null +++ b/src/main/java/io/zipcoder/WordParser.java @@ -0,0 +1,23 @@ +package io.zipcoder; + +import java.util.ArrayList; +import java.util.Arrays; + +public class WordParser { + +public void parseFirstWord(){ + + String firstInput = ""; + + for (String word : firstInput.split(" ")){ + + } + +} + + + + + + +} diff --git a/src/test/java/io/zipcoder/Problem1Test.java b/src/test/java/io/zipcoder/Problem1Test.java index de82e99..5ae2728 100644 --- a/src/test/java/io/zipcoder/Problem1Test.java +++ b/src/test/java/io/zipcoder/Problem1Test.java @@ -1,4 +1,10 @@ package io.zipcoder; + public class Problem1Test { + + + + } + diff --git a/src/test/java/io/zipcoder/WordParserTest.java b/src/test/java/io/zipcoder/WordParserTest.java new file mode 100644 index 0000000..ea3f02c --- /dev/null +++ b/src/test/java/io/zipcoder/WordParserTest.java @@ -0,0 +1,41 @@ +package io.zipcoder; + + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import java.util.ArrayList; +import static org.junit.Assert.*; + +public class WordParserTest { + + private String nothing = ""; + private String inputSentenceFinal = "The Farmer went to the store to get 1 dollar’s worth of fertilizer"; + private String inputSentenceTwoWords = "The Farmer"; + private WordParser woodparser; + +// +// @Before +// public void setUp(){ +// +// } + +// @Test +// public void parseFirstWordTest{ +// woodparser = new WordParser(); +// String expected = "The"; +// String actual = woodparser.parseFirstWord(inputSentenceTwoWords); +// Assert.assertEquals(expected, actual); +// } + + + + + + + + +} + + +