Advertisement
Guest User

zamiana00001

a guest
Jan 22nd, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.21 KB | None | 0 0
  1. public class Funkcje {
  2.  
  3. public static String zmiana(String text, String fraza) {
  4.         String text1 = "";
  5.         String text2 = "";
  6.         String text3 = "";
  7.         int num;
  8.         for (int i = 0; i < text.length(); i++) {
  9.             text2 += text.charAt(i);
  10.             if (Character.isWhitespace(text.charAt(i))) {
  11.                 text1 += " ";
  12.                 //System.out.println(text2);
  13.                 if (text2.equals(fraza)) {
  14.                     for (int j = 0; j < fraza.length(); j++) {
  15.                         text3 += Character.toUpperCase(text2.charAt(i));
  16.                     }
  17.                     //System.out.println(text3);
  18.                     text1 += text3;
  19.                     text3 = "";
  20.                 }
  21.                 text2 = "";
  22.             } else if (Character.isDigit(text.charAt(i))) {
  23.                 num = text.charAt(i) - '0';
  24.                 num += 1;
  25.                 text1 += num;
  26.             } else {
  27.                 text1 += text.charAt(i);
  28.                
  29.             }
  30.         }
  31.         return text1;
  32.     }
  33.    
  34.     public static void main(String[] args) {
  35.         System.out.println(zmiana("Ala ma 2 koty i 9 rybek, ma rowniez  psa", "ma"));
  36.        
  37.     }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement