Java Reference
In-Depth Information
6 drawTop();
7 drawBottom();
8 drawLine();
9 }
10
11 // produces a solid line
12 public static void drawLine() {
13 System.out.print("+");
14 for ( int i = 1; i <= (2 * SUB_HEIGHT); i++) {
15 System.out.print("-");
16 }
17 System.out.println("+");
18 }
19
20 // produces the top half of the hourglass figure
21 public static void drawTop() {
22 for ( int line = 1; line <= SUB_HEIGHT; line++) {
23 System.out.print("|");
24 for ( int i = 1; i <= (line - 1); i++) {
25 System.out.print(" ");
26 }
27 System.out.print("\\");
28 int dots = 2 * SUB_HEIGHT - 2 * line;
29 for ( int i = 1; i <= dots; i++) {
30 System.out.print(".");
31 }
32 System.out.print("/");
33 for ( int i = 1; i <= (line - 1); i++) {
34 System.out.print(" ");
35 }
36 System.out.println("|");
37 }
38 }
39
40 // produces the bottom half of the hourglass figure
41 public static void drawBottom() {
42 for ( int line = 1; line <= SUB_HEIGHT; line++) {
43 System.out.print("|");
44 for ( int i = 1; i <= (SUB_HEIGHT - line); i++) {
45 System.out.print(" ");
46 }
47 System.out.print("/");
48 for ( int i = 1; i <= 2 * (line - 1); i++) {
49 System.out.print(".");
50 }
Search WWH ::




Custom Search