
//   BUG.JAVA          CS 326   Winter 2007,  Homework 2
//                                version Jan. 31, 2007
//
//   Instr. J.Horn   "Review of abstract classes and methods
//
//                See comments below.  You must extend this
//                abstract class with a class of your own,
//                following our usual naming convention:
//                NMUusername+"BugAbstract.java" with the exception that
//                your NMUusername should be initial capped,
//                and you should use "BugAbstract" rather than "Bug".
//                So, for example, "JhornBugAbstract.java".
//                Implement all of the abstract methods below, and
//                any non-abstract methods that you can, and want to,
//                over-write.
//
//                Example of a correct sub-class is in
//                "JhornBugAbstract.java".
//
//                "BugWorld.java" contains a version of the BugWorld
//                to test your Bug, if you want to try it.  A modified
//                version will be used to actually test your Bug, but
//                the "gameworld parameter values" (e.g.,
//                CELL_FOOD_CAPACITY, COST_OF_REPRODUCTION, etc.) will
//                stay the same as in "BugWorld.java".  Note that
//                COST_OF_REPRODUCTION is now set at 10, which is a bit
//                high.


import java.awt.*;


public abstract class Bug implements Cloneable
        {
			private int health_points = 5;

            public abstract int your_move(int [] neighborhood);

            public abstract String getName();

            public abstract void paint(Graphics g);

            public abstract String epitaph();

            public abstract void eat_this(int mum_mum);

            public abstract void lose_this(int health_points);

            public final int get_health_points() {return health_points;}

            public final boolean want_to_reproduce(int cost)
		          {
					if(health_points > cost)
					  return my_want_to_reproduce(cost);
					  else return false;
				  }

            public boolean my_want_to_reproduce(int cost) {return false;}

            public Bug reproduce(int cost)
                 {
					 try {return (Bug) this.clone();}
					 catch (Exception e) {return null;}
				 }

        }


        //  public int your_move(int [] neighborhood);
        //
        //     Returns an int 1 to 9 indicating where you
        //     want to move, using the Moore neighborhood:
        //
        //          1 2 3
        //          4 5 6
        //          7 8 9
        //
        //     Thus "move 5" means stay in place!
        //
        //     The input is an array of 10 integers, with
        //     "neighborhood[i]" giving the number of bugs in cell i.
        //
        //     neighborhood[0] gives your bug's current position in the
        //     vertical stack on the current cell (number 5 in the
        //     Moore neighborhood).  Thus "neighborhood[0] = 1" means
        //     you are on the bottom, while a value of 4 means there are
        //     three underneath you.
        //
        //     The bug on the bottom always to eat 5 units of energy
        //     every turn.  The next bug up gets 4, and so on.  The 6th
        //     bug up gets nothing.
        //
        //     Every bug on top of you increases your chances of getting
        //     squashed by 10%.  Thus with no bugs on you there is a 0%
        //     chance of getting squashed.  With two bugs above there is a
        //     20% chance EACH TURN.  With 10 bugs on top, well ...
        //     Once squashed you are dead and gone.  You can be squashed
        //     at any position in the stack (except of course on top).
        //     You don't have to be on the bottom to get squashed.
        //
        //     It costs you 2 energy units to move, and 1 to sit still,
        //     EVERY TURN!
        //
        //

        //  public String getName();
        //
        //     Return any string <= 20 characters.

        //  public void paint(Graphics g, int x, int y)
        //
        //     Paint yourself, within a 40 by 40 pixel square, with upper
        //     left coordinates x,y.  Stay within the square x to x+40, and
        //     y to y+40, or you won't play!  Also, you must get your initials
        //     or first name in there somewhere, and in a readable form!  (This
        //     will greatly help us figure out who is winning...

        //  public String epitaph();
        //
        //     You have been squashed.  Any last words, return them as a
        //     String < 81 characters, and the BugWorld will print them somewhere
        //     (probably System console window).
        //
        //
        //  public void eat_this(int mum_mum);
        //
        //     The BugWorld has determined that you get to eat "mum_mum" amount of
        //     of food.  Keep track of how much energy/food/health points you have,
        //     if you want to!   Should help you decide what to do next...
        //
        //  public void lose_this(int health_points);
        //
        //    This is the amount that the BugWorld is subtracting from your current
        //    health.
        //
        //  public boolean want_to_reproduce(int cost);
        //
        //    Do you want to reproduce now?  True or false...  "cost" is the current
        //    cost of reproduction.  "cost" points will be subtracted from your health.
        //
        //  public Bug reproduce(int cost);
        //
        //    Return a clone of yourself.  Note that this will cost you "cost" health
        //    points.  Feed your offspring as much mum-mum as you like, but each point
        //    you give your offspring must be subtracted from your own health points!
        //    (Hint:  you can use your offspring's "eat_this" method.  It is public!)
        //    You must do this yourself, and you will be "checked".  (Note that I put
        //    back in a "default" method for you to overwrite.  I remembered that to
        //    properly inherit the "clone() method from the base class "Object", your
        //    class, in this case the abstract class "Bug", has to implement the
        //    "Cloneable" interface, which just means typing "implements Cloneable".)




