diff --git a/pom.xml b/pom.xml index 2a6372d..12152c6 100644 --- a/pom.xml +++ b/pom.xml @@ -7,6 +7,18 @@ io.zipcoder InterviewProblem1 1.0-SNAPSHOT + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + diff --git a/src/main/java/io/zipcoder/Problem1.java b/src/main/java/io/zipcoder/Problem1.java index 6cd6024..44a4945 100644 --- a/src/main/java/io/zipcoder/Problem1.java +++ b/src/main/java/io/zipcoder/Problem1.java @@ -1,4 +1,41 @@ package io.zipcoder; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Collectors; + public class Problem1 { + + public static void main(String[] args) { + + replaceChar(); + + } + + public static void replaceChar() { + + HashMap map = new HashMap<>(); + // ‘f’ : ‘7’, ‘s’:’$’, ‘1’:’!’, ‘a’.:’@’ + map.put('f', '7'); + map.put('s', '$'); + map.put('1', '!'); + map.put('a', '@'); + + String text = "The Farmer went to the store to get 1 dollar’s worth of fertilizer"; + + char[] splitString = text.toCharArray(); + + for (int i = 0; i < splitString.length; i++) { + if (map.containsKey(splitString[i])) { + splitString[i] = map.get(splitString[i]); + } + } + + System.out.println(new String(splitString)); + + + } + + }