Due: Wednesday, February 21, 2018 @ 8:00PM
Write a program that produces the figure below as output. Use static methods to capture the structure and eliminate redundancy. Use for
loops as well to eliminate redundancy within lines. There should be NO print
or println
statements in your main
method, only a few method calls to express the top-level logic. Use less than six method calls in main
(hint: 5).
Do NOT use parameters for this lab, although you MUST use a class CONSTANT to represent the rocket's size. The size of the rocket below is 7.
In subsequent labs I will no longer repeat this paragraph — it should be assumed. Use good programming style: choose DESCRIPTIVE variable and method names, write COMMENTS, and FORMAT your code (Ctrl-Shift-F
). As always, write a COMMENT BLOCK at the top of your program with the FILE NAME, your NAME, the COURSE, the DATE, the LAB NUMBER, and a BRIEF DESCRIPTION of what your program does.
Please name your program Rocket.java
Use good programming style:
Ctrl+Shift+F
will format your code)No user input is required. the size of the rocket 7
should be "hard-coded" into the program as a class static constant. Do not accept any user input for the version you submit, and ensure the version submitted has the value specified.
Use PRECISELY the format shown below with the EXACT same spacing.
/**\
//**\\
///**\\\
////**\\\\
/////**\\\\\
//////**\\\\\\
///////**\\\\\\\
////////**\\\\\\\\
/////////**\\\\\\\\\
//////////**\\\\\\\\\\
///////////**\\\\\\\\\\\
////////////**\\\\\\\\\\\\
/////////////**\\\\\\\\\\\\\
+=*=*=*=*=*=*=*=*=*=*=*=*=*=*+
|....../\............/\......|
|...../\/\........../\/\.....|
|..../\/\/\......../\/\/\....|
|.../\/\/\/\....../\/\/\/\...|
|../\/\/\/\/\..../\/\/\/\/\..|
|./\/\/\/\/\/\../\/\/\/\/\/\.|
|/\/\/\/\/\/\/\/\/\/\/\/\/\/\|
|\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
|.\/\/\/\/\/\/..\/\/\/\/\/\/.|
|..\/\/\/\/\/....\/\/\/\/\/..|
|...\/\/\/\/......\/\/\/\/...|
|....\/\/\/........\/\/\/....|
|.....\/\/..........\/\/.....|
|......\/............\/......|
+=*=*=*=*=*=*=*=*=*=*=*=*=*=*+
|\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
|.\/\/\/\/\/\/..\/\/\/\/\/\/.|
|..\/\/\/\/\/....\/\/\/\/\/..|
|...\/\/\/\/......\/\/\/\/...|
|....\/\/\/........\/\/\/....|
|.....\/\/..........\/\/.....|
|......\/............\/......|
|....../\............/\......|
|...../\/\........../\/\.....|
|..../\/\/\......../\/\/\....|
|.../\/\/\/\....../\/\/\/\...|
|../\/\/\/\/\..../\/\/\/\/\..|
|./\/\/\/\/\/\../\/\/\/\/\/\.|
|/\/\/\/\/\/\/\/\/\/\/\/\/\/\|
+=*=*=*=*=*=*=*=*=*=*=*=*=*=*+
/**\
//**\\
///**\\\
////**\\\\
/////**\\\\\
//////**\\\\\\
///////**\\\\\\\
////////**\\\\\\\\
/////////**\\\\\\\\\
//////////**\\\\\\\\\\
///////////**\\\\\\\\\\\
////////////**\\\\\\\\\\\\
/////////////**\\\\\\\\\\\\\
Use at least 5 static methods. Start method names with a verb
Make a table with line numbers, number of dots per line, number of spaces per line, etc., for each section. Then express the number of each symbol as a function of the line number. You may want to ignore the class constant until you get a good feel for the content of each line. Note the symmetry and the significance of the number seven.
To manage the complexity, develop the program using STEPWISE REFINEMENT as we've been doing in class. Express the overall structure in "main" and create method stubs that only print out that they've been called (e.g., "System.out.println ("In method drawBody"). RUN your program. Once that's working, proceed to the components. For example, write a method to draw the nose cone. Then test that method. Next, write a method that draws the body, noting the symmetry. At first you may leave this method empty or draw a simple line. Continue your development and testing in an ITERATIVE fashion, writing small segments of code and then testing. This will result in significant time savings since you'll have to deal with fewer errors per test.
Submit the Java source code file on Autolab under the "Lab 4" assignment.
for
loops