CS 210 – Fundamentals of Programming I
Spring 2007 – Programming Assignment 6
20 points
Out: March 14/15
Due: March 21/22


(6 points) Consider the following problem statement:


As one part of making one type of quilt, a 2-dimensional square pattern (called a block) is designed. Then the quilt consists of this pattern transformed in various ways. For example, the pattern may be rotated to the left or right by 90 or by 180 degrees, or it may be flipped along the horizontal, vertical, or a diagonal axis. We would like a program to help visualize what these transformations will look like.


For this assignment, we will model a quilt block pattern using an n x n 2-dimensional array of characters that is displayed to the screen. For example, a 5 x 5 pattern might look like:


**** 
*   *
**** 
*    
*    


Write the analysis and design for two (2) functions RotateRight and FlipHorizontal that will receive a quilt block pattern and its size, and pass back the transformed quilt block in a separate 2-D array. I.e., these functions will have 3 parameters and there must not be any display steps in the function. RotateRight will rotate the quilt block pattern 90 degrees to the right and FlipHorizontal will flip the quilt block pattern along the horizontal axis. For the example above, the results of RotateRight and FlipHorizontal, respectively, are shown below.


*****          *    
  * *          *    
  * *          **** 
  * *          *   *
   *           **** 


Use the format shown in class and in the on-line handout An Analysis and Design Style Guideline. Write this part as a comment block in the implementation source file as the function headers as shown in the on-line handout A C++ Programming. Style Guideline for CS 210.


(14 points) Implement an entire program in C++ that will repeatedly ask the user for an n x n quilt block pattern, use the functions designed above to create the two transformed quilt patterns, and display these new quilt block patterns. Filling a pattern array and displaying a pattern array should done using functions. You may assume that the user will input the size of the pattern and that a pattern will be no larger than 50 x 50 characters. The output might look like:


This program will show how a quilt pattern is transformed when
rotated right by 90 degrees and flipped along the horizontal axis.

What is the size of the pattern? 5
Please enter the pattern:

**** 
*   *
**** 
*    
*    

This pattern rotated by 90 degrees is:

*****
  * *
  * *
  * *
   * 

This pattern flipped along the horizontal axis is:

*    
*    
**** 
*   *
**** 

Would you like to do another pattern? (y/n) n

Follow the guidelines in the on-line handout A C++ Programming. Style Guideline for CS 210. As stated in the syllabus, part of the grade on a programming assignment depends on how well you adhere to the guidelines. The grader will look at your code listing and grade it according to the guidelines.


Electronically submit your source file (the .cpp file) by emailing it as an attachment to cs210@csserver.evansville.edu by 4:30pm on the due date. (Make sure you send it to csserver.evansville.edu. If you send to just evansville.edu, it will not be delivered.)


Please note: If you write this program using a system other than Visual Studio, please make sure that your program will compile and run under Visual Studio before you turn it in. Also check that the code is formatted correctly under the Visual Studio editor.