/**
 * Wookie class works as an example to illustrate "pass-by-value" and "pass-by-
 * object" concepts.   It works in tandem with TestWookie.java.
 * CSCE 155 Fall 2005
 * Please run the programs and understand why values are not changed, or why 
 * values are changed.  This is very important.
 *
 * @author Leen-Kiat Soh
 * @version 1.0
 */

class Wookie {

   private String name;
   private int x = 10;          // just a silly variable
   private int force;           // records the strength of 'force' in a Wookie

   /**
    * This is an empty constructor for the Wookie class.
    * It does absolutely nothing.
    */

   public Wookie()  {
   }

   /**
    * This constructor takes an integer as the initial value for the data 
    * member 'force'.  
    * @param force the force strength of a Wookie
    */
   
   public Wookie(int force, String name)  {
      this.force = force;      // note the use of 'this'.  Understand 'this'.
      this.name = name;
   }

   public void setName(String name)  {
       this.name = name;
       }

   /**
    * This method does something to the parameter 'z' and prints out a 
    * confirmation message.
    * @param z an integer
    */

   public void doSomething(int z)  {

      z = 100;
      System.out.println("Yes, I have changed the number to 100");

   }  // end doSomething

   /**
    * This method does something to the parameter 'y' and returns that 
    * parameter.
    * @param y an integer
    * @return <code>int</code> the final value of 'y'.
    */

   public int doSomethingAgain(int y)  {

      y = y + x;
      return y;

   }  // end doSomethingAgain

   /**
    * This method is the setter for 'force'.  
    * @param x an integer for 'force' strength.
    */

   public void setForce(int x)  {
      force = x;
   }

   /**
    * This method is the getter for 'force'.
    * @return <code>int</code> the value of force of the Wookie object
    */

   public int getForce()  {
      return force;
   }

   public String getName()  {
      return name;
   }
   /**
    * This method set the 'force' of the 'chosen' pupil to 0.  It expects an 
    * Wookie object as the parameter.
    * @param chosen a Wookie object/instance
    */

   public void acceptPupil(Wookie chosen)  {
      chosen.setForce(0);
   }

   public String composeInfo()  {
      
      String str = "(name " + name + ")";
      str += "(force " + force + ")";
      return str;

      }

   public void printInfo()  {

      System.out.println(composeInfo());

      }
}  // end Wookie class


