annotate tree-single_file/Ascii.java @ 18:b5e2aba31fdb

lamertetris-0.230821-3 package for arch
author Przemyslaw <prymula76@outlook.com>
date Sun, 31 Mar 2024 15:35:26 +0200
parents 2787f5e749ae
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
prymula <prymula76@outlook.com>
parents:
diff changeset
1 /*
prymula <prymula76@outlook.com>
parents:
diff changeset
2 * ASCII - choinka ze znaków
prymula <prymula76@outlook.com>
parents:
diff changeset
3 * autor: PRP
prymula <prymula76@outlook.com>
parents:
diff changeset
4 * licencja: GPL
prymula <prymula76@outlook.com>
parents:
diff changeset
5 * edytor: Geany
prymula <prymula76@outlook.com>
parents:
diff changeset
6 * 22-02-2022
prymula <prymula76@outlook.com>
parents:
diff changeset
7 *
prymula <prymula76@outlook.com>
parents:
diff changeset
8 * po prostu uruchom przez:
prymula <prymula76@outlook.com>
parents:
diff changeset
9 * java Ascii.java
prymula <prymula76@outlook.com>
parents:
diff changeset
10 *
prymula <prymula76@outlook.com>
parents:
diff changeset
11 */
prymula <prymula76@outlook.com>
parents:
diff changeset
12
prymula <prymula76@outlook.com>
parents:
diff changeset
13 class Ascii {
prymula <prymula76@outlook.com>
parents:
diff changeset
14 static class Sign {
prymula <prymula76@outlook.com>
parents:
diff changeset
15 Sign(){}
prymula <prymula76@outlook.com>
parents:
diff changeset
16 static void show(String s, int n, int max) {
prymula <prymula76@outlook.com>
parents:
diff changeset
17
prymula <prymula76@outlook.com>
parents:
diff changeset
18 if (n < max) {
prymula <prymula76@outlook.com>
parents:
diff changeset
19 System.out.print(s);
prymula <prymula76@outlook.com>
parents:
diff changeset
20 ++n;
prymula <prymula76@outlook.com>
parents:
diff changeset
21 show(s, n, max);
prymula <prymula76@outlook.com>
parents:
diff changeset
22 }
prymula <prymula76@outlook.com>
parents:
diff changeset
23 return;
prymula <prymula76@outlook.com>
parents:
diff changeset
24 }
prymula <prymula76@outlook.com>
parents:
diff changeset
25 }
prymula <prymula76@outlook.com>
parents:
diff changeset
26 static class Triangle extends Sign{
prymula <prymula76@outlook.com>
parents:
diff changeset
27
prymula <prymula76@outlook.com>
parents:
diff changeset
28 static final int SPACE = 24;
prymula <prymula76@outlook.com>
parents:
diff changeset
29 static final int max_lines = 8;
prymula <prymula76@outlook.com>
parents:
diff changeset
30 public static int max_space = SPACE;
prymula <prymula76@outlook.com>
parents:
diff changeset
31 public static int max_stars = 1;
prymula <prymula76@outlook.com>
parents:
diff changeset
32 static boolean first = true;
prymula <prymula76@outlook.com>
parents:
diff changeset
33 Triangle(){
prymula <prymula76@outlook.com>
parents:
diff changeset
34 }
prymula <prymula76@outlook.com>
parents:
diff changeset
35 static void show(int start, int n) {
prymula <prymula76@outlook.com>
parents:
diff changeset
36
prymula <prymula76@outlook.com>
parents:
diff changeset
37 if (n < max_lines) {
prymula <prymula76@outlook.com>
parents:
diff changeset
38 show(" ", start+1, max_space);
prymula <prymula76@outlook.com>
parents:
diff changeset
39 show("*", start, max_stars);
prymula <prymula76@outlook.com>
parents:
diff changeset
40 if (first == false)
prymula <prymula76@outlook.com>
parents:
diff changeset
41 show("*", start+1, max_stars);
prymula <prymula76@outlook.com>
parents:
diff changeset
42 first = false;
prymula <prymula76@outlook.com>
parents:
diff changeset
43 max_space--;
prymula <prymula76@outlook.com>
parents:
diff changeset
44 max_stars++;
prymula <prymula76@outlook.com>
parents:
diff changeset
45 System.out.println("");
prymula <prymula76@outlook.com>
parents:
diff changeset
46 ++n;
prymula <prymula76@outlook.com>
parents:
diff changeset
47 show(start, n);
prymula <prymula76@outlook.com>
parents:
diff changeset
48 }
prymula <prymula76@outlook.com>
parents:
diff changeset
49 return;
prymula <prymula76@outlook.com>
parents:
diff changeset
50 }
prymula <prymula76@outlook.com>
parents:
diff changeset
51 }
prymula <prymula76@outlook.com>
parents:
diff changeset
52 static class Tree extends Triangle {
prymula <prymula76@outlook.com>
parents:
diff changeset
53 static final int MAX_SEQUENCES= 3;
prymula <prymula76@outlook.com>
parents:
diff changeset
54 static int l = 1; // degress left spaces
prymula <prymula76@outlook.com>
parents:
diff changeset
55 static void print(int start, int n) {
prymula <prymula76@outlook.com>
parents:
diff changeset
56 if (n < MAX_SEQUENCES) {
prymula <prymula76@outlook.com>
parents:
diff changeset
57 show(start, 1);
prymula <prymula76@outlook.com>
parents:
diff changeset
58 start--;
prymula <prymula76@outlook.com>
parents:
diff changeset
59 max_space = SPACE-2*l;
prymula <prymula76@outlook.com>
parents:
diff changeset
60 max_stars = 1;
prymula <prymula76@outlook.com>
parents:
diff changeset
61 ++n;
prymula <prymula76@outlook.com>
parents:
diff changeset
62 l+=1;
prymula <prymula76@outlook.com>
parents:
diff changeset
63 print(start, n);
prymula <prymula76@outlook.com>
parents:
diff changeset
64 }
prymula <prymula76@outlook.com>
parents:
diff changeset
65 return;
prymula <prymula76@outlook.com>
parents:
diff changeset
66 }
prymula <prymula76@outlook.com>
parents:
diff changeset
67 }
prymula <prymula76@outlook.com>
parents:
diff changeset
68
prymula <prymula76@outlook.com>
parents:
diff changeset
69
prymula <prymula76@outlook.com>
parents:
diff changeset
70 public static void main (String args[]){
prymula <prymula76@outlook.com>
parents:
diff changeset
71 Tree t = new Tree();
prymula <prymula76@outlook.com>
parents:
diff changeset
72 final int START_SEQUENCES =0;
prymula <prymula76@outlook.com>
parents:
diff changeset
73 final int GOOD = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
74 System.out.println("");
prymula <prymula76@outlook.com>
parents:
diff changeset
75 t.print(GOOD, START_SEQUENCES);
prymula <prymula76@outlook.com>
parents:
diff changeset
76 System.out.println("");
prymula <prymula76@outlook.com>
parents:
diff changeset
77 }
prymula <prymula76@outlook.com>
parents:
diff changeset
78 }