package ru.job4j.loop;

/**
 *@author Nikita Zenkin.
 *@since 30.05.2017.
 *@version 1.
*/

public class Paint {
	/**
	 * @param h int. height of pyramid
	 * @return String.
	*/
	 public String pyramid(int h) {
		 StringBuilder s = new StringBuilder();
		 for (int i = 0; i < h; i++) {
			 for (int j = 0; j < h - i - 1; j++) {
				 s.append(" ");
			 }
			 for (int j = h - i - 1; j < h + i; j++) {
				 s.append("^");
			 }
			 for (int j = 0; j < h - i - 1; j++) {
				 s.append(" ");
			 }
			 s.append(System.getProperty("line.separator"));
		 }
		 return s.toString();
	 }
}
@@ -295,37 +295,39 @@
 (int j = 0; j %3C 
-h - i
+(2 * h)
  - 1; j++) %7B%0A%09%09%09
@@ -332,44 +332,16 @@
 %09%09%09 
-s.append(%22 %22);%0A%09%09%09 %7D%0A%09%09%09 for (int 
+if ((
 j 
+%3E
 = h 
@@ -347,18 +347,22 @@
  - i - 1
-; 
+) && (
 j %3C h + 
@@ -362,29 +362,25 @@
  %3C h + i
-; j++
+)
 ) %7B%0A%09%09%09%09
  s.appen
@@ -363,32 +363,33 @@
 %3C h + i)) %7B%0A%09%09%09%09
+%09
  s.append(%22%5E%22);%0A
@@ -395,53 +395,20 @@
 %0A%09%09%09
+%09
  %7D
-%0A%09%09%09 for (int j = 0; j %3C h - i - 1; j++)
+ else
  %7B%0A
+%09
 %09%09%09%09
@@ -423,16 +423,23 @@
 d(%22 %22);%0A
+%09%09%09%09 %7D%0A
 %09%09%09 %7D%0A%09%09

Task 4412 v2