CSCI 161: Rocket
Objectives
- Write a Java Project from scratch
- Learn how to declare and use static variables
- Learn how to use for-loops
- Decompose output to several methods
- Use good naming conventions when creating variables
- Leverage your improved knowledge of the Java programming language to produce the desired output
- Make awesome figures
Overview
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. You must only make
method calls tp in main
.
Do NOT use parameters for this lab, although you MUST use a static class VARIABLE 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
Style
Use good programming style:
- Write comments
- Choose mnemonic, meaningful variable names (e.g. seconds, minutes)
- Indent consistently (Ctrl+Shift+F will format your code)
- Remember the comment block at the top of your program
Input Specification
No user input is required. The size of the rocket 7
should be “hard-coded” into the program as a static class variable (do
not make the variable final
since we need
to resize the figure for testing). Do not accept any
user input for the version you submit, and ensure the version submitted
has the value specified.
Output Specification
Use PRECISELY the format shown below with the EXACT same spacing.
/**\
//**\\
///**\\\
////**\\\\
/////**\\\\\
//////**\\\\\\
///////**\\\\\\\
////////**\\\\\\\\
/////////**\\\\\\\\\
//////////**\\\\\\\\\\
///////////**\\\\\\\\\\\
////////////**\\\\\\\\\\\\
/////////////**\\\\\\\\\\\\\
+=*=*=*=*=*=*=*=*=*=*=*=*=*=*+
|....../\............/\......|
|...../\/\........../\/\.....|
|..../\/\/\......../\/\/\....|
|.../\/\/\/\....../\/\/\/\...|
|../\/\/\/\/\..../\/\/\/\/\..|
|./\/\/\/\/\/\../\/\/\/\/\/\.|
|/\/\/\/\/\/\/\/\/\/\/\/\/\/\|
|\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
|.\/\/\/\/\/\/..\/\/\/\/\/\/.|
|..\/\/\/\/\/....\/\/\/\/\/..|
|...\/\/\/\/......\/\/\/\/...|
|....\/\/\/........\/\/\/....|
|.....\/\/..........\/\/.....|
|......\/............\/......|
+=*=*=*=*=*=*=*=*=*=*=*=*=*=*+
|\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
|.\/\/\/\/\/\/..\/\/\/\/\/\/.|
|..\/\/\/\/\/....\/\/\/\/\/..|
|...\/\/\/\/......\/\/\/\/...|
|....\/\/\/........\/\/\/....|
|.....\/\/..........\/\/.....|
|......\/............\/......|
|....../\............/\......|
|...../\/\........../\/\.....|
|..../\/\/\......../\/\/\....|
|.../\/\/\/\....../\/\/\/\...|
|../\/\/\/\/\..../\/\/\/\/\..|
|./\/\/\/\/\/\../\/\/\/\/\/\.|
|/\/\/\/\/\/\/\/\/\/\/\/\/\/\|
+=*=*=*=*=*=*=*=*=*=*=*=*=*=*+
/**\
//**\\
///**\\\
////**\\\\
/////**\\\\\
//////**\\\\\\
///////**\\\\\\\
////////**\\\\\\\\
/////////**\\\\\\\\\
//////////**\\\\\\\\\\
///////////**\\\\\\\\\\\
////////////**\\\\\\\\\\\\
/////////////**\\\\\\\\\\\\\
Required Methods
Use at least 5 static methods. Start method names with a verb. Consider how the rocket should be decomposed. Identify where there is replication.
Hints and Reminders
- First and foremost, stay calm :-) The figure may be a little intimidating, but you can solve this.
- It may help if you have an EXAMPLE from class in front of you.
- Add some meaningful comments that indicate what each method does
- Do NOT forget your top comment block with filename, name, date, course, and description
- Ensure your program works for any size greater than 1
- Create a new project for this lab. If you forget how, review the first lab
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.
Submission
Submit the Java source code file on Autolab under the “Rocket” assignment.
Grading
- 20 points will be awarded for having a well-formatted, well-documented source code file. This includes your name, date, description, and comments throughout the program. This also includes other style requirements, such as method naming conventions. NOTE: The autograder will not display these points.
- 35 points will be awarded for proper decomposition and well-written
for
loops- 5 points for the “border”
- 10 points for the “cone”
- 10 points for each of the two unique parts of the body
- 45 points will be awarded for matching the desired output
- 5 points for the “border”
- 10 points for the “cone”
- 10 points for each of the two unique parts of the body
- 10 points for the overall program output
- NOTE: if your program does not compile/run, the highest score you will earn will be a 20/100