UMBC CMSC201, Computer Science I, Fall 1994
Section 0101, 0102 and Honors
Project 3
Due: Wednesday, November 9, 1994
Objective:
The main objective of this assignment is to practice
writing a function to fit into a particular library interface.
Assignment:
Hashmark Greeting Cards has agreed to buy our course's calendar
program to be used in the production of their 1995 calendars.
However, they need to have an additional feature implemented in
this program. They want to be able to print the numbers in
calendar in various sizes, so they can print large or small
calendars using the same program.
We have agreed to add this feature by printing large numbers
using asterisks. (See examples in the next page.)
Most of this program has already been implemented. Your assignment
is to provide a function called DigitFont, which has the
following function prototype:
int DigitFont(int digit, int row, int nrows, int ncols) ;
The purpose of this function is to provide information about the
shape of digit when it is to be printed in nrows
rows and ncols columns. For example, if we intend to
print the digit 9 using 5 rows and 4 columns, it might
look like:
****
* *
****
*
****
Then, a function call to DigitFont(9,1,5,4) should tell us to print
4 asterisks in the first row and a call to Digit(9,2,5,4) should
tell us to print 1 asterisk, followed by 2 spaces and another asterisk in
the second row. This information will be represented by the numbers 1111 and 1001
respectively; i.e., these numbers should be returned by the function calls
DigitFont(9,1,5,4) and DigitFont(9,2,5,4). The ones in the
number represent asterisks and the zeroes represent spaces.
Note: you do not have to implement the functions that plot these
characters --- you only have to provide the DigitFont function.
Implementation Notes:
Honors Section:
Students in the honors section should implement this project with a new
twist. The numbers returned by DigitFont should be interpreted as
binary numbers. For example, the numbers returned by
DigitFont(9,1,5,4) and DigitFont(9,2,5,4) should be 15 and
9 in decimal --- these numbers are 1111 and 1001 in binary. Since
int variables can hold 31-digit binary numbers, the constants in
proj3.h need to be different. You should copy the files
cal-funcs.o, proj3h.h, main3h.o and test3h.o
instead of the ones mentioned above. The compilation commands will use
different file names, too. Also, include a sample run of numbers
with 31 columns when you submit your project.
What to turn in:
Use the script command to save a copy of your output.
To do this, remove any old typescript files you have,
type script, run your program to duplicate
the sample runs below and then type exit at the prompt.
Use an editor (e.g., emacs)
to check that the file actually contains your output before you turn it in.
When you have successfully created the typescript file,
and have deleted all the blank lines at the end of your program,
submit your program using the submit201 command
that you copied for Project~1. To submit both your project and the
typescript file, issue the command:
% submit201 proj3.c typescript
Please check your own mail to see if you have submitted the correct files.
Sample Runs:
retriever% cc201 test3.o proj3.c
test3.c:
proj3.c:
retriever% a.out
number to print =? 1994
number of rows =? 10
number of columns =? 8
* ******** ******** * *
* * * * * * *
* * * * * * *
* * * * * * *
* * * * * * *
* ******** ******** ********
* * * *
* * * *
* * * *
* ******** ******** *
retriever%
retriever% a.out
number to print =? 12345
number of rows =? 12
number of columns =? 10
* ********** ********** * * **********
* * * * * *
* * * * * *
* * * * * *
* * * * * *
* * * * * *
* ********** ********** ********** **********
* * * * *
* * * * *
* * * * *
* * * * *
* ********** ********** * **********
retriever%
retriever% cc201 main3.o proj3.c cal-funcs.o
retriever% a.out
number of rows =? 5
number of columns =? 5
year =? 1994
month =? 3
********** * ********** ********** * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
********** * ********** ********** **********
* * * * *
* * * * *
* * * * *
* * * * *
********** * ********** ********** *
---------------------------------------------------------------------------------------------------
| | | * | ***** | ***** | * * | ***** |
| | | * | * | * | * * | * |
| | | * | ***** | ***** | ***** | ***** |
| | | * | * | * | * | * |
| | | * | ***** | ***** | * | ***** |
---------------------------------------------------------------------------------------------------
| ***** | ***** | ***** | ***** | * ***** | * * | * ***** |
| * | * | * * | * * | * * * | * * | * * |
| ***** | * | ***** | ***** | * * * | * * | * ***** |
| * * | * | * * | * | * * * | * * | * * |
| ***** | * | ***** | ***** | * ***** | * * | * ***** |
---------------------------------------------------------------------------------------------------
| * ***** | * * * | * ***** | * ***** | * ***** | * ***** | * ***** |
| * * | * * * | * * | * * | * * | * * * | * * * |
| * ***** | * ***** | * ***** | * ***** | * * | * ***** | * ***** |
| * * | * * | * * | * * * | * * | * * * | * * |
| * ***** | * * | * ***** | * ***** | * * | * ***** | * ***** |
---------------------------------------------------------------------------------------------------
| ***** ***** | ***** * | ***** ***** | ***** ***** | ***** * * | ***** ***** | ***** ***** |
| * * * | * * | * * | * * | * * * | * * | * * |
| ***** * * | ***** * | ***** ***** | ***** ***** | ***** ***** | ***** ***** | ***** ***** |
| * * * | * * | * * | * * | * * | * * | * * * |
| ***** ***** | ***** * | ***** ***** | ***** ***** | ***** * | ***** ***** | ***** ***** |
---------------------------------------------------------------------------------------------------
| ***** ***** | ***** ***** | ***** ***** | ***** ***** | ***** * | | |
| * * | * * * | * * * | * * * | * * | | |
| ***** * | ***** ***** | ***** ***** | ***** * * | ***** * | | |
| * * | * * * | * * | * * * | * * | | |
| ***** * | ***** ***** | ***** ***** | ***** ***** | ***** * | | |
---------------------------------------------------------------------------------------------------
retriever%
retriever% a.out
number of rows =? 5
number of columns =? 3
year =? 1994
month =? 4
* * * ****** ****** * *
* * * * * * * * *
* * * * * * * * *
* * * * * * * * *
* * * * * * * * *
****** * ****** ****** ******
* * * * *
* * * * *
* * * * *
* * * * *
* * ****** ****** *
-----------------------------------------------------------------------
| | | | | | * | *** |
| | | | | | * | * |
| | | | | | * | *** |
| | | | | | * | * |
| | | | | | * | *** |
-----------------------------------------------------------------------
| *** | * * | *** | *** | *** | *** | *** |
| * | * * | * | * | * | * * | * * |
| *** | *** | *** | *** | * | *** | *** |
| * | * | * | * * | * | * * | * |
| *** | * | *** | *** | * | *** | *** |
-----------------------------------------------------------------------
| * *** | * * | * *** | * *** | * * * | * *** | * *** |
| * * * | * * | * * | * * | * * * | * * | * * |
| * * * | * * | * *** | * *** | * *** | * *** | * *** |
| * * * | * * | * * | * * | * * | * * | * * * |
| * *** | * * | * *** | * *** | * * | * *** | * *** |
-----------------------------------------------------------------------
| * *** | * *** | * *** | *** *** | *** * | *** *** | *** *** |
| * * | * * * | * * * | * * * | * * | * * | * * |
| * * | * *** | * *** | *** * * | *** * | *** *** | *** *** |
| * * | * * * | * * | * * * | * * | * * | * * |
| * * | * *** | * *** | *** *** | *** * | *** *** | *** *** |
-----------------------------------------------------------------------
| *** * * | *** *** | *** *** | *** *** | *** *** | *** *** | *** *** |
| * * * | * * | * * | * * | * * * | * * * | * * * |
| *** *** | *** *** | *** *** | *** * | *** *** | *** *** | *** * * |
| * * | * * | * * * | * * | * * * | * * | * * * |
| *** * | *** *** | *** *** | *** * | *** *** | *** *** | *** *** |
-----------------------------------------------------------------------
retriever%
Last Modified:
Wed Oct 26 15:04:52 EDT 1994
Richard Chang, chang@gl.umbc.edu