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