/**
 * Models a small, safe, blob-like entity that grows when you feed it.
 * Fun for the whole family!  Now comes in cool designer colors.
 *
 * This class demonstrates instance variables, constructors, and
 * instance methods.
 *
 * @author Zach Tomaszewski
 * @version 13 Mar 2009
 */
public class PetBlob {

  //instance variables: every PetBlob instance gets its own copy of these
  public String name;
  public int size;
  public String color;


  //constructors

  /**
   * Creates a new PetBlob with the given name, size, and color.
   *
   * Any size (in cubic centimeters?) of less than 1 will be treated as 1.
   */
  public PetBlob(String name, int size, String color) {
    //Since we used the same name for the parameters as for the instance
    //variables, we MUST use this. here to differentiate the two
    this.name = name;
    if (size < 1) {
      this.size = 1;
    }else {
      this.size = size;
    }
    this.color = color;
  }

  /**
   * Creates a new PetBlob with the given name, size of 1, and purple color.
   */
  public PetBlob(String name) {
    //we can actually reuse the constructor above to do the initializing work
    this(name, 1, "purple");
  }

  /**
   * Creates an empty, unitialized PetBlob.
   */
  public PetBlob() {
    //This constructor does nothing.  It's basically the same as the default
    //constructor that java will insert for you if you don't write a
    //constructor at all.
  }


  //instance (non-static) methods

  /**
   * Feeding a PetBlob causes it to grow in size by the amount it was fed.
   */
  public void feed(int amountOfFood) {
    this.size = this.size + amountOfFood;
  }

  /**
   * Feeds this PetBlob a small snack of a single unit of food, causing it
   * to increase in size by 1.
   */
  public void feed() {
    //this is an example of method overloading.
    //Again, we can reuse the other form to do the work if we want to
    this.feed(1);
  }

  /**
   * PetBlobs, like slugs, often leave behind a trail of mucus.
   * The production of this mucus can be rather exhausting for them, however,
   * causing them to decrease in size by 1 each time they do it.
   */
  public void secreteMucus() {
    this.size -= 1;
  }

  /**
   * Prints the state of this PetBlob to the screen.
   */
  public void print() {
    System.out.println('"' + this.name + "\", a " + this.color +
                       " PetBlob of size " + this.size);
  }

}
