/**
 * Jedi class works as an example to illustrate "pass-by-value" and "pass-by-
 * object" concepts.   It works in tandem with TestJedi.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
 */

import java.io.*;

class Jedi {

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

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

   public Jedi()  {
//       name = "dummy";
       // x = 5;
       force = 10;
   } 

   public Jedi(int initForce)  {
      name = "dummy";
      force = initForce;
   }


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

   /*
   public Jedi(int force)  {
      this.force = force;
      this.name = "dummy";

      }
      */

   public void setName(String name)  {
       name = "MasterWindu";
       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");
      System.out.println("z = " + z);

   }  // 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)  {
      if (x > 9)
         force = -9;
      else
         force = x;
   }

   public void turnJediIntoEvil()  {

      instillHate();
      makeLightSaberRed();
      makeHisOrHerLovedOnesDead();
      makeHisOrHerClothesDarker();
   }


   /**
    * This method is the getter for 'force'.
    * @return <code>int</code> the value of force of the Jedi 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 
    * Jedi object as the parameter.
    * @param chosen a Jedi object/instance
    */

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

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

      }

   public void printInfo()  {

      System.out.println(composeInfo());

      }

   private void instillHate()  {

      // do something
      }
     
   private void makeLightSaberRed() {

      // do something complicated

   }

   private void makeHisOrHerLovedOnesDead() {
      // do something and enjoy doing it
      //
   }

   private void makeHisOrHerClothesDarker()  {

      // check with props people

   }

}  // end Jedi class


