(Latest Revision: 01/18/2002)
01/18/2002: Corrected some typographical errors.
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:
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 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 do exactly the same inputs 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 your program
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.)
I think you can make a copy of each image just by displaying the image file
in your browser and saving it in a directory or folder. You will need some
image files for testing your program.
I also put some image files here --->
ftp://splendor.csustan.edu/pub/john/ascii_images/ where you can use a
file transfer program (ftp) to get them.
I can give you a demonstration in class on how to use ftp to get files.
OUTPUT:
The program will write all its output to standard output (the default
standard output is the screen).
As the sample run of the program shows, the
program runs in a cycle. First it prints 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 to the standard
output.
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 to work with -- an
array big enough to hold any of the images we will be using for input.
When the program performs a tiling, it must first copy 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:
You are responsible for deciding what testing you need to do on your 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 be sending 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.
- Always use the exact subject line I specify for each message.
(I get hundreds of e-mail messages at a time and your subject line
allows me to sort messages.)
- Be very careful when typing the command to send e-mail. You may use
the instructions in your
Hello World! lab excercise
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 immediately 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:
- Send the following items to me by e-mail before midnight on the
first due date:
A
level two version of the source code,
with subject line: CS2500,prog1.2.
and
a script
showing your test runs, with subject line:
CS2500,scrp1.2.
- Send the following items to me by e-mail before midnight on the
second due date:
A
final version of the source code,
with subject line: CS2500,prog1.f.
and a script showing your test runs, with subject line:
CS2500,scrp1.f.
(You can look
here
and
here
for samples of scripts. However, to determine what you need to put in
your final script, you will need to incorporate what you learn from our
class discussions concerning testing.)
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.