@Test public void runTest() { assertEquals("AAAALRMAMWA", Beaufort.beaufort("TESTINGTHIS", "TEST")); assertEquals("TESTINGTHIS", Beaufort.beaufort("AAAALRMAMWA", "TEST")); }
public static String beaufort(String input, String key) { input = input.toLowerCase(); StringBuilder output = new StringBuilder(); char[] plain = input.toCharArray(); char[] keyw = key.toCharArray(); int keyLength = keyw.length; int index = 0; for (char c : plain) { if (findIndex(c) != -1) { output.append(getCharBeaufort(c, keyw[index])); index = (index + 1) % keyLength; } } return output.toString().toUpperCase(); }
Beaufort { public static String beaufort(String input, String key) { input = input.toLowerCase(); StringBuilder output = new StringBuilder(); char[] plain = input.toCharArray(); char[] keyw = key.toCharArray(); int keyLength = keyw.length; int index = 0; for (char c : plain) { if (findIndex(c) != -1) { output.append(getCharBeaufort(c, keyw[index])); index = (index + 1) % keyLength; } } return output.toString().toUpperCase(); } }
Beaufort { public static String beaufort(String input, String key) { input = input.toLowerCase(); StringBuilder output = new StringBuilder(); char[] plain = input.toCharArray(); char[] keyw = key.toCharArray(); int keyLength = keyw.length; int index = 0; for (char c : plain) { if (findIndex(c) != -1) { output.append(getCharBeaufort(c, keyw[index])); index = (index + 1) % keyLength; } } return output.toString().toUpperCase(); }  }
Beaufort { public static String beaufort(String input, String key) { input = input.toLowerCase(); StringBuilder output = new StringBuilder(); char[] plain = input.toCharArray(); char[] keyw = key.toCharArray(); int keyLength = keyw.length; int index = 0; for (char c : plain) { if (findIndex(c) != -1) { output.append(getCharBeaufort(c, keyw[index])); index = (index + 1) % keyLength; } } return output.toString().toUpperCase(); }  static void main(String[] args); static String beaufort(String input, String key); }
Beaufort { public static String beaufort(String input, String key) { input = input.toLowerCase(); StringBuilder output = new StringBuilder(); char[] plain = input.toCharArray(); char[] keyw = key.toCharArray(); int keyLength = keyw.length; int index = 0; for (char c : plain) { if (findIndex(c) != -1) { output.append(getCharBeaufort(c, keyw[index])); index = (index + 1) % keyLength; } } return output.toString().toUpperCase(); }  static void main(String[] args); static String beaufort(String input, String key);  }