first commit

This commit is contained in:
DrChic0 committed 2024-03-07 11:19:37 -08:00
commit 1e19e7f773
7 files changed
+173

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
public class wordSandwich {
private String[] wordSandwiches;
public wordSandwich(String str1, String str2) {
makeAllSandwiches(str1, str2);
}
private void makeAllSandwiches(String str1, String str2) {
wordSandwiches = new String(str1.length() - 1);
for(int i = 0; i < wordSandwiches.length; i++) {
wordSandwiches[i] = makeSandwich(str1, str2, i + 1);
}
}
private String makeSandwich(String str1, String str2, int n) {
return str1.substring(0, n) + str2 + str1.substring(n);
}
public String[] getFillings(int start, int end) {
String[] result = new String(wordSandwiches.length);
for(int i = 0; i < wordSandwiches.length; i++) {
result[i] = wordSandwiches[i].substring(start, end);
}
return result;
}
}