Java Reference
In-Depth Information
18
public static void
drawX() {
19 System.out.println(" \\ /");
20 System.out.println(" \\ /");
21 System.out.println(" \\ /");
22 System.out.println(" /\\");
23 System.out.println(" / \\");
24 System.out.println(" / \\");
25 System.out.println();
26 }
27
28
public static void
drawRocket() {
29 System.out.println(" /\\");
30 System.out.println(" / \\");
31 System.out.println(" / \\");
32 System.out.println("+------+");
33 System.out.println("| |");
34 System.out.println("| |");
35 System.out.println("+------+");
36 System.out.println("|United|");
37 System.out.println("|States|");
38 System.out.println("+------+");
39 System.out.println("| |");
40 System.out.println("| |");
41 System.out.println("+------+");
42 System.out.println(" /\\");
43 System.out.println(" / \\");
44 System.out.println(" / \\");
45 }
46 }
The program appears in a class called
DrawFigures2
and has four static methods
defined within it. The first static method is the usual
main
method, which calls three
methods. The three methods called by
main
appear next.
Figure 1.3 is a structure diagram for this version of the program. Notice that it has
two levels of structure. The overall problem is broken down into three subtasks.
main
drawDiamond
drawX
drawRocket
Figure 1.3
Decomposition of
DrawFigures2
Search WWH ::
Custom Search