Homework 11


Upon completing this assignment, you will be able to:


This assignment will be of a different nature than previous assignments. It covers more topics and is due in the last week of class, which is frequently an overloaded time. This homework will therefore consist of mini-problems touching on different topics which can be done incrementally, rather than one big design problem. Note that each problem is associated with a topic covered in lecture in the last two weeks of class - if you are not sure where to start for a particular problem, review that day's lecture/activities.

  1. (Event handlers)Write a program that draws an ellipse to the screen. When the mouse is dragged (i.e. pressed and moved), the ellipse resizes so that the mouse position forms an outside corner of the ellipse (you may find it helpful to use ellipseMode(CORNERS)). Your program should (a) not run when the mouse is not being dragged (i.e., it should use noLoop() in setup() and not call loop() elsewhere) and (b) should have no commands in the draw() function.
  2. (Multiple constructors) The program petrie draws cells moving around on a petrie dish. Alter this program so that when the mouse button is pressed, a new cell in a random gray tone appears. For this problem, you may not alter any code in the petrie file. You may only add additional constructors to the Cell file and any functions you find useful to the HandleMouse file.
  3. (Combined objects) The program combine contains two classes: a growing circle and a pulsing circle. Write a program that combines objects from each of these two classes into a third class called Circle, which has a growing circle and a pulsing circle anchored at the same point. The program should draw a Circle at a random location when it is started. Every time the mouse is released, it should replace the current Circle with a new Circle at the mouseY, mouseY position of the mouse. You may choose sizes and colors of the circles as you prefer.
  4. (Recursion)The program littleBoxes uses the function drawSquares() to draw a square which is split up into 4 smaller boxes. Make this function recursive by replacing each of the randomSquare calls to draw the smaller boxes with a call to drawSquares() itself. The function should stop recursion when the size of the square to be drawn is less than 1 pixel.

Submission instructions

Please submit a zipped folder which contains all four problems.

Grading scheme

A+ - All problems included and functioning correctly. Code is clean, clear and well-documented.

A - All problems included and functioning correctly. Code is mostly clean, clear and well-documented.

B - Competent response to the assignment showing overall mastery of course material, with some small errors that do not greatly affect the quality of the assignment. For example, the code may be somewhat baroque (too complex for what it does), or the code may be formatted incorrectly, the code completely misses on one of the problems, but overall demonstrates understanding of the unit's material.

C - Some bigger errors, or a larger collection of smaller errors, but with potential to develop into a competent response. For example, the code may not run, but with a few small syntactical fixes would properly fulfill the assignment; the code may work but not be comprehensibly written; the code completely misses on two of the problems, but still shows some understanding of the unit's material.

D - Serious errors show clear effort, but serious gaps in understanding, such as code that does not run and is not close to being correct, or solves only one problem.

F - Little demonstrated effort, or clear effort with no understanding, such as code fragments submitted which are only the start of a response to the assignment.