-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChristmasTree.java
More file actions
47 lines (42 loc) · 1.19 KB
/
ChristmasTree.java
File metadata and controls
47 lines (42 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//Xmas tree creator
public class ChristmasTree {
public static void main(String[] args) {
drawTree(3, 4);//sample tree sizes
drawTree(2, 5);
}
public static void drawTree(int num1, int scalar){
for(int i=0;i<num1;i++){//number of triangles in stack
for (int line=1;line<=scalar;line++){//triangle creator, analagous to rocket
for(int space=num1-i; space>=0;space--){
System.out.print(" ");
}
for(int spaces=1; spaces<=line*-1+(scalar);spaces++){
System.out.print(" ");
}
for(int dots=1; dots<=line+i;dots++){
System.out.print("*");
}
for(int dots=1; dots<(line+i);dots++){
System.out.print("*");
}
for(int spaces=1; spaces<=line*-1+(scalar);spaces++){
System.out.print(" ");
}
System.out.print("\n");
}
}
for(int space=scalar+num1-1; space>=0;space--){//offsets base
System.out.print(" ");
}
System.out.println("*");
for(int space=scalar+num1-1; space>=0;space--){// " "
System.out.print(" ");
}
System.out.println("*");
for(int space=scalar-4+num1; space>=0;space--){// " "
System.out.print(" ");
}
System.out.println("*******\n");
}
}
//EOF