/**
 * This program creates a few sample SafePetBlobs.
 * It demonstrates how to call constructors and instance methods.
 *
 * @author Zach Tomaszewski
 * @version 17 Mar 2009
 */
public class SafePetStore {

  public static void main(String[] args) {

    //The point of this class is to call every method of a SafeBlob and test
    //that each really behaves the way it is meant to.  There are better ways
    //to structure such tests, but this way makes for more amusing output.

    //creates some blobs.  Note how we have to use one of these two constuctor
    //forms now; "new SafePetBlob()" won't work anymore.
    SafePetBlob firstBlob = new SafePetBlob("Wilbur", 100, "green");
    SafePetBlob secondBlob = new SafePetBlob("Wilfred", 5, "blue");
    SafePetBlob thirdBlob = new SafePetBlob("Saunders");

    //Now we can print out each of the 3 new blobs (testing toString())
    System.out.println("There were once 3 PetBlobs in the pet store: ");
    System.out.println(firstBlob.toString());
    System.out.println(secondBlob.toString());
    //does the same as previous two lines: toString() is invoked implicitly
    System.out.println(thirdBlob);
    System.out.println();

    //Testing renaming feature: getName() and setName()
    System.out.print(firstBlob.getName() + " was purchased and renamed to ");
    firstBlob.setName("McGuffin");
    System.out.println(firstBlob.getName() + ".");

    //Test feed(int), isDead(), and getSize()
    System.out.print("Fed 100 units of food every day, ");
    int days = 0;
    while (!firstBlob.isDead()) {
      //Constant feeding will eventually exceed the int data type
      firstBlob.feed(100);
      days++;
    }
    System.out.println(firstBlob.getName() + " lived " + days +
                      " days before exploding.");
    System.out.println("(Size after death: " + firstBlob.getSize() + ")");
    System.out.println();

    //Test secreteMucus() and feed()
    System.out.println("Young " + thirdBlob.getName() +
                       " tried to crawl away before being fed.");
    //since size was originally 1, this will kill the blob.  :(
    thirdBlob.secreteMucus();
    System.out.println("Though we prodded him with a stick a couple times... ");
    //test that size really doesn't decrease when dead
    thirdBlob.secreteMucus();
    thirdBlob.secreteMucus();
    System.out.println("and offered him some tidbits...");
    //and feeding doesn't revive him
    thirdBlob.feed();
    System.out.println("it seems he really was dead.");
    System.out.println("(Size: " + thirdBlob.getSize() + ")");
    System.out.println();

    System.out.print(secondBlob.getName());
    System.out.print(" (the " + secondBlob.getColor() + " one)");
    System.out.println(" didn't sell for a long time.");
    System.out.print("We thought maybe he was too big ");
    System.out.println("(Size: " + secondBlob.getSize() + ")");
    System.out.print("  but feeding him silica gel had no effect. ");
    //feeding negative amounts should do nothing
    secondBlob.feed(-3);
    System.out.println("(Size: " + secondBlob.getSize() + ")");
    System.out.print("A bit of exercise helped though. ");
    secondBlob.secreteMucus();
    System.out.println("(Size: " + secondBlob.getSize() + ")");

    System.out.println("This shows that a balanced regimen of diet and ");
    System.out.println("exercise can keep your SafePetBlob alive forever.");

    //uncomment for an infinite loop
    //while (!secondBlob.isDead()) {
    //  secondBlob.feed();
    //  secondBlob.secreteMucus();
    //}

  }

}
