CMSC110 (Introduction to Computing)

Fall 2016

Assignment #6

Due by 1:10pm on Wednesday, November 30 (RE) / 12:55pm on Thursday, December 1 (DK)

First, read Chapter 6 from GXK.

Task: Design an underwater creature.

Your creature should be written as a class that implements the Creature interface. Make sure you name the class as <YourFirstInitialLastName>Thingy. For example Deepak Kumar's creature will be defined in a class called DKumarThingy. Richard Eisenberg's creature will be REisenbergThingy. You should be able to create instances of the creature with varying sizes. (In other words, your class's constructor must take a size parameter.)

Here is the Creature interface:

 
interface Creature
{
 void display(); // draw the creature to the screen
 void move(); // have the creature swim or otherwise move
}

Naturally, your class will have to implement both of these methods.

We will be taking your creature and all of your classmates' creatures and having them swim together in the same aquarium. Here is what the aquarium sketch might look like:

 
Creature[] g_creatures;
 
void setup() {
  size(800, 600);
  background(0, 0, 200); // blue background
 
  g_creatures = new Creature[6]; // 3 of DKumar, 3 of REisenberg
  for(int i = 0; i < 3; i++) {
     g_creatures[i] = new DKumarThingy(random(30,50)); // choose a random size
  }
  for(int i = 3; i < 6; i++) {
    g_creatures[i] = new REisenberg(random(40,60)); // make these a bit bigger
  }
} // setup
 
void draw() {
  // update and move all the creatures
  for(Creature c : g_creatures) {
     c.move();
     c.display();
  }
} // draw

Requirements:

Note: This assignment does not require a main sketch (with setup() and draw()); you are just writing one class. But you will want to write a main sketch to test your design.

What to Hand in: Hand in your class online. Make sure to include:

1.    Your class code (the .pde file)

2.    A gif/jpg/png image of your finished creature

3.    A write-up with your name, course and assignment number and a paragraph about the creature, its inspiration, and how you designed and implemented it. Include a brief discussion about your experience working on this assignment.

Hand in a printout of all three in class on the due date.