package ru.szhernovoy;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Created by admin on 17.07.2016.
 */
public class Polindrom {
    public static void main(String[] args) {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Polindrom pol = new Polindrom();
        boolean result = false;
        do {
            System.out.print("\nPlease , enter string polindrom (example KOMOK): ");
            try {
                result = pol.polindromTest(pol.getPolindrom(br.readLine()));
                if (result) {
                    System.out.println("This is a polindrom");
                }
                else{
                    System.out.println("This is not a polindrom");
                }

            } catch (StringLengthException exc) {
                System.out.println(exc);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        while (!result);
    }

    public String getPolindrom(String testString) throws StringLengthException {
        if (testString.length() != 5) {
            throw new StringLengthException(testString);
        }
        return testString;
    }

    public boolean polindromTest(String testString) {

        boolean result = false;
        char[] array = testString.toLowerCase().toCharArray();
        if (array[0] == array[4] && array[1] == array[3]) {
            result = true;
        }
        return result;
    }
}

@@ -1308,36 +1308,35 @@
 oolean result = 
-fals
+tru
 e;%0A        char%5B
@@ -1398,53 +1398,139 @@
    i
-f (array%5B0%5D == array%5B4%5D && 
+nt j = 0;%0A        for(int i = testString.length() - 1; i %3E=0; i-- )%7B%0A            if(j %3C i)%7B%0A                if(
 array%5B
-1%5D =
+j++%5D !
 = array%5B
 3%5D) 
@@ -1529,14 +1529,21 @@
 ray%5B
-3
+i
 %5D)
- 
 %7B%0A
+        
     
@@ -1563,23 +1563,140 @@
 t = 
-true;%0A        %7D
+false;%0A                    break;%0A                %7D%0A            %7D%0A            else %7B%0A                break;%0A            %7D%0A        %7D%0A
 %0A   

update lesson1 polindrom