package ru.job4j;

/**.
* Chapter_002
* Extra task
* Check validate brackets
*
* @author Anton Vasilyuk
* @version 1.0
* @since 0.1
*/

public class CheckBrackets {

	/**.
	* It's method for check brackets
	* @param brackets is array brackets
	* @return result
	*/
	public boolean checkBreckets(char[] brackets) {
		boolean result = true;

		char a = '(';
		char b = ')';

		int aNum = 0;
		int bNum = 0;
	
		for (int index = 0; index < brackets.length; index++) {
			if (brackets[index] == a) {
				aNum++;
			}
			if (aNum < bNum) {
			result = false;
			break;
			}
			if (brackets[index] == b) {
				bNum++;
			}
			if (aNum < bNum) {
			result = false;
			break;
			}
		}
		return result;
	}
}
@@ -386,24 +386,8 @@
  0;%0A
-%09%09int bNum = 0;%0A
 %09%0A%09%09
@@ -494,64 +494,8 @@
 %09%09%7D%0A
-%09%09%09if (aNum %3C bNum) %7B%0A%09%09%09result = false;%0A%09%09%09break;%0A%09%09%09%7D%0A
 %09%09%09i
@@ -529,14 +529,14 @@
 %09%09%09%09
-bNum++
+aNum--
 ;%0A%09%09
@@ -556,12 +556,9 @@
 m %3C 
-bNum
+0
 ) %7B%0A
@@ -595,16 +595,51 @@
 %09%09%7D%0A%09%09%7D%0A
+%09%09if (aNum != 0) %7Bresult = false;%7D%0A
 %09%09return

add file for chapter_002_2.9.1