view tree-single_file/Ascii.java @ 15:f61684ae8245

READEM FIX
author prymula <prymula76@outlook.com>
date Sat, 10 Feb 2024 21:05:36 +0100
parents 2787f5e749ae
children
line wrap: on
line source

/*
 * 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("");
    }
}