Assessment Tool

Lecture 12:  Functions and Design

Content Tested:  Extending the call graph

Lecture Content:

Goals:

Assessment Technique:  Design Activity

Purpose:

Instructors can find out if students understand functional decomposition in the context of building a picture of a house.  The lecture portion describes the calling tree or static call graph for drawing a simple picture of a house.  Students will add to this design new components of the house and describe where new functions would fit into the existing calling tree.

Activity:

In today's lecture we saw the functional decomposition of a program to draw a house.  Suppose we want to add features to the picture.  Think of things to add to the simple house picture.  Once you have decided on the new features of your house picture, please draw them on the diagram and add corresponding functions to the calling tree (also known as the static call graph).  Remember that the primitive drawing functions are Rectangle, Triangle, Circle, and Line.


 

(Hint:  Some features you might consider include a chimney, a fence, and shutters for the windows.)
 

After you have added features to the picture and to the calling graph, please write the C code for one or more of your new functions.  A model is the following code for draw_window.

void draw_window (int x, int y){
    /* (x,y) is the lower left corner of the window */
    rectangle(WHITE, x, y, x + WIN_W, y + WIN_H);
    line(x + MID_X, y, x + MID_X, y + WIN_H);
    line(x, y + MID_Y, x + WIN_W, y + MID_Y);
}

Prototypes for the primitive drawing functions are listed below.

void rectangle(int color, int left_lower_x, int left_lower_y, int right_upper_x,
               int right_upper_y);
void triangle(int color, int x1, int y1, int x2, int y2, int x3, int y3);
void circle(int color, int center_x, int center_y, int radius);
void line(int x1, int y1, int x2, int y2);
 

Possible Solutions:

Students might add functions draw_chimney, draw_shutter, and draw_fence to the calling tree.  The function draw_chimney might call the function line.  Draw_fence might call the functions rectangle and line.  The C implementation of one of these functions will depend on where the students place these items in their drawings.

Possible Uses of Activity: