forked from Ryan-Karanja/APCSA
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRocketship
More file actions
109 lines (97 loc) · 2.79 KB
/
Rocketship
File metadata and controls
109 lines (97 loc) · 2.79 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//this code makes a rocket ship using input from the user
import java.util.Scanner;
public class rocket {
// this part uses methods created by ryan to make the cone, divider and other parts of the rocket ship
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
System.out.print("Size of Rocket: ");
int size = scnr.nextInt();
drawCone(size);
drawDivider(size);
System.out.print("\n");
drawTopBody(size);
drawBottomHalf(size);
drawDivider(size);
System.out.println();
drawBottomHalf(size);
drawTopBody(size);
drawDivider(size);
System.out.println();
drawCone(size);
System.out.println();
}
//produces the top cone
public static void drawCone(int size){
//makes lines
for(int line = 1; line <= (size * 2 - 1); line++){
//makes spaces
for(int space = 1; space <= (size * 2 - line); space++){
System.out.print(" ");
}
//makes /
for(int slash = 1; slash <= line; slash++){
System.out.print("/");
}
//makes *
System.out.print("**");
//makes \
for(int slash = 1; slash <= line; slash++){
System.out.print("\\");
}
//makes spaces
for(int space = 1; space <= (size * 2 - line); space++){
System.out.print(" ");
}
System.out.print("\n");
}
}
public static void drawDivider(int size) {
//produces dividing line
System.out.print("+");
for (int i = 1; i <= size * 2; i++) {
System.out.print("=*");
}
System.out.print("+");
}
//produces the top half of the body
public static void drawTopBody(int size) {
for (int line = 1; line <= size; line++) {
System.out.print("|");
for (int repeat = 1; repeat <= 2; repeat++) {
for (int dots = 1; dots <= size - line; dots++) {
System.out.print(".");
}
for (int points = 1; points <= line; points++) {
System.out.print("/\\");
}
for (int dots = 1; dots <= size - line; dots++) {
System.out.print(".");
}
}
System.out.println("|");
}
}
public static void drawBottomHalf(int size) {
//makes line
for (int line = size; line >= 1; line--) {
System.out.print("|");
//repeats nesting twice
for (int repeat = 1; repeat <= 2; repeat++) {
//makes dots
for (int dots = 1; dots <= size - line; dots++) {
System.out.print(".");
}
//makes \/
for (int points = 1; points <= line; points++) {
System.out.print("\\/");
}
//makes dots in outside
for (int dots = 1; dots <= size - line; dots++) {
System.out.print(".");
}
}
System.out.println("|");
}
}
}
System.out.println("Hello!");