diff tree-single_file/Ascii.java @ 0:2787f5e749ae

INIT
author prymula <prymula76@outlook.com>
date Thu, 21 Sep 2023 22:33:57 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tree-single_file/Ascii.java	Thu Sep 21 22:33:57 2023 +0200
@@ -0,0 +1,78 @@
+/*
+ * ASCII - choinka ze znaków
+ * autor: PRP
+ * licencja: GPL
+ * edytor: Geany
+ * 22-02-2022
+ * 
+ * po prostu uruchom przez:
+ * java Ascii.java
+ *  
+ */
+
+class Ascii {
+	static class Sign {
+		Sign(){}
+		static void show(String s, int n, int max) {
+	
+			if (n < max) {
+				System.out.print(s);
+				++n;
+				show(s, n, max);
+			}
+			return;
+		}
+	}
+	static class Triangle extends Sign{
+	
+		static final int SPACE = 24;
+		static final int max_lines = 8;
+		public static int max_space = SPACE;
+		public static int max_stars = 1;
+		static boolean first = true;
+		Triangle(){
+		}
+		static void show(int start, int n) {
+
+			if (n < max_lines) {
+				show(" ", start+1, max_space);
+				show("*", start, max_stars);
+				if (first == false)
+					show("*", start+1, max_stars);
+				first = false;
+				max_space--;
+				max_stars++;
+				System.out.println("");
+				++n;
+				show(start, n);
+			}
+			return;
+		}
+	}
+	static class Tree extends Triangle {
+		static final int MAX_SEQUENCES= 3;
+		static int l = 1; // degress left spaces
+		static void print(int start, int n) {
+			if (n < MAX_SEQUENCES) {
+				show(start, 1);
+				start--;
+				max_space = SPACE-2*l;
+				max_stars = 1;
+				++n;
+				l+=1;
+				print(start, n);
+			}
+			return;
+		}
+	}
+	
+	
+    public static void main (String args[]){
+		Tree t = new Tree();
+		final int START_SEQUENCES =0;
+		final int GOOD = 0;
+        System.out.println("");
+        t.print(GOOD, START_SEQUENCES);
+        System.out.println("");
+    }
+}