CIS 254 Intro to Object Oriented Program Design

Project 8.1

This program is broken down into phases for your convenience only. Please turn in only your final product.

Phase 1: Write a program that draws a rocket on the screen. Here's what the rocket should look like:

  X
 X X
X   X
XXXXX
X   X
X   X
X   X
X   X
XXXXX
XXXXX
X   X
X   X
X   X
X   X
XXXXX
  X
 X X
X   X

Your main function in phase 1 must look like this:

    int main()
    {
        drawCone();    
        drawBox();
        drawBox();
        drawCone();
    }

You may use three cout statements (no loops are necessary) in your drawCone() function. For your drawBox() function, you must use the drawHorizontalLine(), draw2VerticalLines(), and drawOneRow() functions exactly as they appear in lesson 6. For phase 1 you'll be using the versions from lesson 6.3.

Phase 2: In this phase you will allow the user to specify three things:

  1. the height of each stage
  2. the width of each stage
  3. how many stages in the rocket

(A "stage" in your rocket is one rectangle. The example rocket above has a stage-height of 6, a stage-width of 5, and the number of stages is 2.)

Your main method in phase 2 must look like this:

    int main() {
        <declarations>
        
        <6 statements to prompt for and read the stage-height, stage-width,
            and number of stages.>
            
        drawRocket(<arguments>);
    }

In order to make this work with the zyBooks unit tester, we'll need to agree on an order for the arguments. Here's the rule: the width of the rocket, if it is an argument, must always be first. The number of stages in the rocket, if it is an argument, must always be last.

You must use the drawHorizontalLine(), draw2VerticalLines(), drawOneRow(), drawBox() functions exactly as they appear in lesson 6.7.

Here is a sample output. Note that you'll need to match the text of the prompts exactly in order to pass zyBooks.

enter width: 5
enter height of each stage: 8
enter number of stages: 3
  X  
 X X 
X   X
XXXXX
X   X
X   X
X   X
X   X
X   X
X   X
XXXXX
XXXXX
X   X
X   X
X   X
X   X
X   X
X   X
XXXXX
XXXXX
X   X
X   X
X   X
X   X
X   X
X   X
XXXXX
  X  
 X X 
X   X

Notice that if you run the program and choose a different width for your stages, the cone won't fit correctly anymore. I won't make you fix this (in other words, you can keep your three line drawCone() function from phase 1) but you can fix it for 5 points of extra credit if you like. However, I will not help you with the extra credit. In order to get the extra credit, the number of rows of your cone must be equal to the width of the stages divided by 2 (plus 1 for odd widths). If the stage width is an even number, your cone must have two stars in the top row instead of one. If you do this perfectly and use good decomposition in the process you'll get 5 extra credit points.

Note on zyBooks and the extra credit: zyBooks will mark your solution as incorrect if you place any spaces to the right of the final "X" on a line of your output. Very rarely, a solution that incorporates the extra credit may do this. In order to pass the zyBooks tests, you must not print any spaces to the right of the final "X" on a line of your output.

Phase 3: In this phase you won't change what the program produces. We're just going to improve on the organization a bit. Change your program so that the main function looks like this:

    int main()
    {
        <declarations>

        getDimensions(<arguments>);
        drawRocket(<arguments>);    
    }

You must still use the drawBox(), drawHorizontalLine(), draw2VerticalLines(), and drawOneRow() functions exactly as they appear in lesson 6.7. They should remain unchanged from phase 2. (Note: since you'll be using these four functions directly from the lesson, you are not required to document them.)

As described in the Style Conventions, please make sure to place a detailed comment above each of your function definitions, use good decomposition, and separate your functions with at least 6 blank lines. I suggest that now would be a good time to reread the Style Conventions section of the Syllabus. Note that you are not required to provide documentation for functions that you copied from the lesson.