(Latest Revision: 02/07/2008)
Arrays: Tiling With Ascii Art
PRELIMINARIES:
You need to learn about top down design and array indexing to do this
assignment properly. Do the reading in Carrano and come to lectures.
You also need to read the directions and examples here:
http://www.cs.csustan.edu/~john/Classes/General_Info/progAsgRules/
THE ASSIGNMENT:
According to my specifications, you will write a program that tiles a
rectangular area with a piece of ascii art.
INPUT:
Your program will have two main sources of input. There will be keyboard
input from the user of the program and input from files.
Have a look at a
sample run of the program.
user input:
As illustrated by the sample run, the user tells the program whether to
continue by entering 'y' or 'n'. When the user wishes to continue, s/he
must enter the name of a specially formatted ascii image file. Also s/he
must enter the dimensions of the desired tiling (number of tiles across,
and number of tiles down).
It is very important to me that your program
perform exactly the same input operations as shown in the sample, in exactly
the same order. Also your program must not input anything "extra."
I will test the programs in an automated fashion with a script that contains
prepared answers to the prompts. I will be required to
do extra work to test your program if it does not conform to the input
rules. In that case, you will lose significant credit.
file input:
The specially formatted ascii image files look like this bee
file and this bird file.
Each image file starts with a pair of numbers on the first line. These
numbers tell the dimensions of the ascii image in the file. The first
number tells how many lines are in the image, and the second number tells
how many characters are in each line of the image. (To make your
programming job easier, the number of characters in each line of the image is
the same. Lines that appear shorter are actually padded with blanks to make
up the length.)
You will need to make some image files for testing your program. I think
you can make a copy of each image in the assignment directory just by
displaying the image file in your browser, selecting, pasting into an
editor buffer, and saving as a file in a directory or folder.
I also put some image files here --->
ftp://splendor.csustan.edu/pub/john/ascii_images/ where you can use a
file transfer program (sftp) to obtain copies of image files for testing.
I can give you a demonstration in class on how to use sftp to get files.
OUTPUT:
The program must write all its output to standard output (the default
standard output is the screen).
As the sample run of the program shows, the
program must run in a cycle. First it writes a message asking the user if
s/he wants to perform a tiling. If the user answers with the letter
y, the program prompts for and gets the parameters from the user
and then does the tiling by writing copies of the image across and down.
After doing the tiling the program goes back to the beginning of the cycle.
When the user answers with the letter n instead of y, the
program simply stops.
PROCESSING:
One reason I am assigning this program is to give you practice using a
rectangular array.
Declare a global constant like this in your program:
const int MAXSIDE = 100 ;
Also, declare a character buffer array like this in your main program:
char buffer [MAXSIDE][MAXSIDE] ;
This gives your program a 100 X 100 array of characters (named buffer)
to work with: an array big enough to hold any of the images we will be using
for input.
You are required to write the program so that when it performs a tiling, it
first copies the image from the file into the "upper left corner" of the
array (I'll explain more about that in class). Then the program must make
the tiling by repeatedly copying portions of the array to the standard
output in a certain controlled way (I'll talk more about that too.)
EXAMPLE PROGRAM RUNS:
You may follow these links to see sample runs of a couple of different
levels of my solution to this programming problem:
TESTING:
A programmer must be responsible for deciding what testing s/he needs to do
on the program in order to verify it is correct. Testing can count for
fifteen percent or more of your grade. The script of your tests must
demonstrate adequate data coverage and code coverage.
For adequate data coverage, you need to think of
- cases of average input, and
- cases of boundary input
and test those cases.
For adequate code coverage you need to make sure that all the
statements in your program execute during the testing.
We can discuss more about testing strategy in class.
WHAT TO TURN IN:
You will turn in four printer outputs (hardcopies) and you will send me four
e-mail messages. Please follow these rules:
- Always send me e-mail as plain text in the main message body. Never send
me attachments.
If you use a program with a graphical user interface (GUI) to compose
e-mail, usually you can send text just by pasting it into "the message
window." Also, if you are using a unix machine, a command like
mail -s "CS2500_prog1.1" john@ishi.csustan.edu < myprog1.1.cpp
will do the trick.
- Always use the exact subject line I specify for each message.
(I often get hundreds of e-mail messages in a week. The subject line
allows me to find, filter and sort messages.) You will lose a
significant number of points on the assignment if you use the wrong
subject line.
- Be very careful when performing the commands to send e-mail. If you
want, you may use the 'unix' example above or the instructions in your
Hello World! lab exercise
for guidance. Of course, you will need to make the obvious changes to
those directions -- you have to use the correct subject line and
filename.
- Always send yourself a copy of each e-mail message you send to me, and
check to see if you receive the message intact. You are
responsible for sending e-mail correctly.
Here is the list of things you have to turn in:
- At the start of class on the
first due date,
place the following items on the 'counter' in front of me:
- a hardcopy of a
level-one version of the program source code, and
- a hardcopy of your
test script showing adequate testing of your
level-one program.
Make sure that all of the source code and script content shows on the
paper. Make sure all content is plainly readable and properly formatted.
- Send the following items to me by e-mail before midnight on the
first due date:
- At the start of class on the
second due date,
place the following items on the 'counter' in front of me:
- a hardcopy of a
final version of the program source code, and
- a hardcopy of your
test script showing adequate testing of your
finished program.
Make sure that all of the source code and script content shows on the
paper. Make sure all content is plainly readable and properly formatted.
- Send the following items to me by e-mail before midnight on the
second due date:
(You can look
here
and
here
for samples of script contents. However, to determine what you need to
put in your own scripts, you will need to incorporate what you learn from our
class discussions concerning testing. You must design tests, show in your
scripts that you executed the tests, and show that the tests succeeded.)
Note that there are no spaces in the subject lines given above. It is
important that you do not insert any spaces. My e-mail address is:
john@ishi.csustan.edu .
DUE DATES:
For the due dates, see
the class schedule.