package ru.job4j.finaltask;

/**
*Find substring in String. Task 6 final.
*@author Dmitriy Bobrov (mailto:bobrov.dmitriy@gmail.com)
*@since 0.1
*/

public class SubString {
/**
*Class Substring. Find sustring in String.
*/

/**
*Is there any substring in String.
*@param origin - String.
*@param sub - Substring.
*@return boolean - returns whether the substring part of the string.
*/
	public boolean contains(String origin, String sub) {
		char[] originArr = origin.toCharArray();
		char[] subArr = sub.toCharArray();

		int lengthSub = subArr.length;
		int count = 0;

       for (int i = 0; i < subArr.length;) {
            for (int j = 0; j < originArr.length;) {
                if (subArr[i] == originArr[j]) {
                    count++;
                    if (count == lengthSub) {
                        return true;
                    }
                    i++;
                    j++;
                } else {
                    if (j < originArr.length) {
                    	j++;
                    }
                    count = 0;
                }
            }
        }
		return (count == lengthSub);
	}
}
@@ -567,24 +567,25 @@
  0;%0A%0A       
+ 
 for (int i =
@@ -683,16 +683,37 @@
     if (
+i == subArr.length & 
 subArr%5Bi
@@ -714,17 +714,17 @@
 bArr%5Bi%5D 
-=
+!
 = origin
@@ -757,15 +757,13 @@
     
-count++
+i = 0
 ;%0A  
@@ -780,96 +780,162 @@
     
-    if (count == lengthSub) %7B%0A                        return true;%0A                    %7D
+%7D%0A                if (subArr%5Bi%5D == originArr%5Bj%5D) %7B%0A                    count++;%0A                    i++;%0A                    j++;%0A                %7D else %7B
 %0A   
@@ -944,34 +944,36 @@
                i
-++
+ = 0
 ;%0A              
@@ -970,35 +970,41 @@
                 
-j++
+count = 0
 ;%0A              
@@ -1001,37 +1001,51 @@
             
-%7D else %7B%0A    
+    j++;%0A                %7D%0A
             
@@ -1052,26 +1052,28 @@
     if (
-j %3C origin
+count == sub
 Arr.leng
@@ -1102,12 +1102,35 @@
     
-%09j++
+return (count == lengthSub)
 ;%0A  
@@ -1130,32 +1130,39 @@
 ub);%0A           
+     %7D%0A
          %7D%0A     
@@ -1158,39 +1158,91 @@
     
-%7D%0A                    count = 0
+       if (j == originArr.length) %7B%0A                    return (count == lengthSub)
 ;%0A  
@@ -1281,18 +1281,24 @@
       %7D%0A
-%09%09
+        
 return (

Task 6.0 subString