Assessment Tool

Java course:  Methods

Content Tested:  Control Flow and Data Flow of a Method Invocation

Lecture Content:

Goals:

Assessment Technique:  Mini-Drama

Purpose:

To allow instructors to find out if students understand the execution of a method call in terms of control flow and data flow.  This activity will give students a chance to design their own model of a method call and help them remember the actions associated with a method call.
 

Activity:


Today we will learn more about the process of a method call which you saw in a recent lecture.  In a group of 3-4 people, design a mini-drama that demonstrates the method call process for the following code.  First, the code for the class ARectangle is given.  Act out the method call process of the sequence of statements following the class implementation.

/**
 * A simple rectangle object that can be drawn on the screen
 *
 */

public class ARectangle {
    int    x;                 // distance from left edge of rectangle  
                              // left edge of screen
    int    y;                 // distance from top edge of rectangle to top
                              // edge of screen
    int    width;             // width of the rectangle
    int    height;            // height of the rectangle
    boolean fill;             // True if rectangle is solid
    Color  color;             // Color of the rectangle

    /** construct a new rectangle object
    * @param xPosition position of left edge of rectangle
    * @param yPosition position of top edge of rectangle
    * @param origWidth width of rectangle
    * @param origHeight height of rectangle
    */
    public ARectangle(int xPosition, int yPosition,
                      int origWidth, int origHeight){
         this.x = xPosition;
         this.y = yPosition;
         this.width = origWidth;
         this.height = origHeight;
         this.fill = true;           // newly constructed rectangles
                                     // are filled
         this.color = Color.white;   // newly constructed rectangles are
                                     // white

    /** set size of rectangle
    * @param w width of rectangle
    * @param h height of rectangle
    */
    public void setSize(int w, int h){
         this.width = w;
         this.height = h;
    }

    /** set location of rectangle
    * @param newX location of rectangle left edge
    * @param newY location of rectangle right edge
    */
    public void setLocation(int newX, int newY){
         this.x = newX;
         this.y = newY;
    }

    /** set color of rectangle
    * @param c new color
    */
    public void setColor(Color c){
         this.color = c;
    }

    /** set to fill
    */
    public void setToFill(){
         this.fill = true;
    }

    /** set to outline
    */
    public void setToOutline(){
         this.fill = false;
    }
}

Invent a drama that illustrates the following code:

rect = new ARectangle(10, 10, 200, 300);
rect.setToOutline();
rect.setColor(Color.blue);
rect.setSize(400, 100);
 

You may want to split up the roles as the "director" person, the "object" person, and the "methods" person who gives messages to the "object" person.  Props such as cards or pieces of paper with variable names and values might also be helpful.

After spending about 10 minutes creating your drama, we will share these with the rest of the class.


Possible Uses of Activity: