This repository has been archived on 2026-10-15. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
2024-03-11 12:33:03 -07:00

27 lines
864 B
Java

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;
}
}