Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Funkcje {
- public static String zmiana(String text, String fraza) {
- String text1 = "";
- String text2 = "";
- String text3 = "";
- int num;
- for (int i = 0; i < text.length(); i++) {
- text2 += text.charAt(i);
- if (Character.isWhitespace(text.charAt(i))) {
- text1 += " ";
- //System.out.println(text2);
- if (text2.equals(fraza)) {
- for (int j = 0; j < fraza.length(); j++) {
- text3 += Character.toUpperCase(text2.charAt(i));
- }
- //System.out.println(text3);
- text1 += text3;
- text3 = "";
- }
- text2 = "";
- } else if (Character.isDigit(text.charAt(i))) {
- num = text.charAt(i) - '0';
- num += 1;
- text1 += num;
- } else {
- text1 += text.charAt(i);
- }
- }
- return text1;
- }
- public static void main(String[] args) {
- System.out.println(zmiana("Ala ma 2 koty i 9 rybek, ma rowniez psa", "ma"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement