Due: Thursday 2/13 10:00am

Submission name: w05_organisms

Thursday 2/13 Update:

Use the class descriptions below, and by the end of Friday 2/14 you should have the following classes:


  flowchart TD
    A[Organism] -->B[MovingOrganism]
    A --> C[CustomClass0]
    B --> D[CustomClass1]
    B --> E[CustomClass2]

Test your classes in your driver file.

Overview

Over the next few days, we will create an aquarium program. In this program we will have an Tank class, which will contain various subclasses of some root class (and possibly others). When the program is run, we will see the aquarium, and all of the animals in it moving about.

Starter Classes

Here is the UML diagram for Organism which will be our main superclass:


  classDiagram
    class Organism {
        int size
        PVector position
        int health

        Organism(int s, int x, int y, int h)
        display()
        age()
    }
  • Create the Organism superclass.
  • Make one subclass, MovingOrganism, which will be for any tank denizens that can move around. Add instance variables and methods as needed.
  • Make a subclass of MovingOrganism (we wont be creating instances of MovingOrganism). To start, the subclass may only differ from MovingOrganism in how it appears.
  • Make a subclass of Organism that would represent a living thing that does not move (like a plant or a coral…).
  • Create a driver file that tests your subclasses.

PImages

To start, have your display() methods use basic processing shapes. Once you get your classes working, you may want to use a picture in display(). There is a processing class called PImage that you can use. Here is a simple example:

PImage pic = loadImage("nemo.png"); //create the PImage object
pic.resize(50, 50); //change the size (width, height)
image(pic, 25, 10); //draw the image at pixel (25, 10) - upper-left

In order for this to work nemo.png must be a file that is in your sketch directory.