mirror of
https://github.com/exituser/Brewery.git
synced 2026-09-17 07:49:03 +00:00
Changed words replace from while to for
This commit is contained in:
@@ -228,14 +228,13 @@ public class Words {
|
|||||||
}
|
}
|
||||||
// remove all "from" and split "words" there
|
// remove all "from" and split "words" there
|
||||||
String[] splitted = words.split(from);
|
String[] splitted = words.split(from);
|
||||||
int index = 0;
|
|
||||||
String part;
|
String part;
|
||||||
|
|
||||||
// if there are occurences of "from"
|
// if there are occurences of "from"
|
||||||
if (splitted.length > 1) {
|
if (splitted.length > 1) {
|
||||||
// - 1 because dont add "to" to the end of last part
|
// - 1 because dont add "to" to the end of last part
|
||||||
while (index < splitted.length - 1) {
|
for (int i = 0; i < splitted.length - 1; i++) {
|
||||||
part = splitted[index];
|
part = splitted[i];
|
||||||
// add current part of "words" to the output
|
// add current part of "words" to the output
|
||||||
newWords = newWords + part;
|
newWords = newWords + part;
|
||||||
// check if the part ends with correct string
|
// check if the part ends with correct string
|
||||||
@@ -247,10 +246,10 @@ public class Words {
|
|||||||
// add original
|
// add original
|
||||||
newWords = newWords + from;
|
newWords = newWords + from;
|
||||||
}
|
}
|
||||||
index++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the last part to finish the sentence
|
// add the last part to finish the sentence
|
||||||
part = splitted[index];
|
part = splitted[splitted.length - 1];
|
||||||
if (part.equals(" ")) {
|
if (part.equals(" ")) {
|
||||||
// dont add the space to the end
|
// dont add the space to the end
|
||||||
return newWords;
|
return newWords;
|
||||||
@@ -298,5 +297,4 @@ public class Words {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user