Project 2: The Scalable ASCII Space Needle

posted by: Mr. Bergquist 28 September 2011 No Comment

This assignment focuses on for loops, expressions, variables, and constants. Thanks to Marty Stepp and Stuart Reges!  Worth 30 Project Points (new project point system 2015)

Your assignment is to produce a specific text figure that is supposed to look like Seattle’s Space Needle. Turn in a class named SpaceNeedle in a file named You should exactly reproduce the format of the output at left. This includes having identical characters and spacing.

See text files with the needle at the default size (size 4), size 2, size 3 and size 7. You can use a diff tool such as to compare your output. You will be graded both on “external correctness” (whether the program compiles and produces exactly the expected output) and “internal correctness” (whether your source code follows the course coding conventions and the style guidelines
in this document).

As a reference, my solution has 5 methods besides main and occupies around 90-110 lines including comments and blank lines, though you do not have to match this exactly.

This program is intended to test your knowledge of nested for loops so you should use them as appropriate.

Continue to use static methods to structure your solution in such a way that the methods match the structure of the output itself. Avoid significant redundancy; use methods so that no substantial groups of identical statements appear in your code. No println statements should appear in your main method. You do not need to use methods to capture redundancy in partial lines, such as the two groups of colons in the following line:


You are required to properly indent your code and will lose points if you make significant indentation mistakes. No line of your code should be over 100 characters long. Give meaningful names to methods and variables in your code. Follow Java’s naming standards about the format of ClassNames, methodAndVariableNames, and CONSTANT_NAMES. Include a comment header at the beginning of your program with basic information and a description of the program. Also include a comment at the start of each method, describing its behavior.

Class constant for figure’s size

You should create one (and only one) class constant to represent the size of the pieces of the figure. Use 4 as the value of your constant. Your figure must be based on that exact value when you turn it in to receive full credit. On any given execution your program will produce just one version of the figure. However, you should refer to the class constant throughout your code, so that by simply changing your constant’s value and recompiling, your program would produce a figure of a different size. Your program should scale correctly for any constant value of 2 or greater.

Please note that the height of the needle’s midsection grows as the square of the figure size. In the default figure size of 4, the midsection is 16 lines tall. If the size were 7, the midsection would be 49 lines tall.

Development Strategy (How to Get Started):

This program is best completed in stages. I strongly recommend the following development strategy:

  1. Pseudocode: Write out the major sections of the figure and steps needed to display them, all in English.
  2. Tables: Examine the output and write tables to discover the patterns of repeated characters on each line.
  3. Code w/o Constant: Completely write the Java code to draw the Space Needle at its default size of 4.
  4. Code w/ Constant: Add a constant to your code so that the needle can scale to different sizes.

To summarize, you should not worry about the constant at first. Write an initial program without a constant, using loop tables or pseudocode to help you deduce the patterns in the output. After your figure looks correct at the default size, begin a second version with the constant. Think back to the Mirror program for a good example.

Summary of criteria for grading Space Needle Project: 30 Total Points
About half for External Correctness:
- output must match exactly for default size of 4 and…
- when modifying the constant to other values everything scales correctly in the resulting Space Needle
About half for Internal Correctness including:
- using a single static constant to produce the scaling (preferred name is SIZE)
- create Methods to capture structure of the Space Needle and reduce redundancy reasonably
- use nested loops to create patterns
- coding conventions are followed, including commented header, indentations align, and naming conventions are adhered

(thanks again to Ms. Martin for identifying such a keen assignment for our class.)

1 Star2 Stars3 Stars4 Stars5 Stars (21 votes, average: 4.71 out of 5)
Loading ... Loading ...

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>