CS 110 (Introduction to Computing)

Fall 2011 - Section 3

Assignment #03

Due by 4:00 pm on Friday, September 30, 2011

Task: Design an object. This can be whatever you feel like drawing. To manage and draw your object, you should use one of the two following approaches:


Approach 1:

int nObjects = 10;  // Set to the number of objects you would like to draw
float[] ax = new float[nObjects];   // Array of object x-locations
float[] ay = new float[nObjects];   // Array of object y-locations
float[] aw = new float[nObjects];   // Array of object widths
float[] ah = new float[nObjects];   // Array of object heights

void setup() {
  // Initialize sketch and
  // initialize all object property arrays here
}

void draw() {
  // Draw objects here
}

void drawMyObject( float x, float y, float objectWidth, float objectHeight ) 
{
    // Your drawing code here ...
}

Approach 2:

int nObjects = 10;  // Set to the number of objects you would like to draw
MyObject[] objects = new MyObject[nObjects];

void setup() {
  // Initialize sketch and
  // Create all objects here
}

void draw() {
  // Draw objects here
}

class MyObject {
  
  // Declare object fields (variables) here
  
  // Constructor
  MyObject(float tx, float ty, float objectWidth, float objectHeight) {
    // Initialize object here
  }
  
  void draw() {
    // Draw object here using its field values
  }
}

Requirements:

Pay special attention to the aesthetic aspects of your design as well as interactivity. Your sketch should be creative!!

Hints:

Carefully read the Assignment Submission Policy for how to submit your assignment.