/**
 * Jedi2 class works as an example to illustrate how to best implement a
 * "comparison" method for reference data typse.  This works in tandem with
 * TestJedi2.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 Jedi2 {

   private String name;
   private int force;           // records the strength of 'force' in a Jedi2

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

   public Jedi2()  {
   }

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

   /** 
    * This method set the force of the Jedi2 to an integer value.
    * @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 Jedi2 object
    */

   public int getForce()  {
      return force;
   }

   /**
    * This method returns the name of the Jedi2 object.
    * @return <code>String</code> the name of the Jedi2 object
    */

   public String getName()  {
      return name;
   }

   /**
    * This method compares the Jedi2 object to another given Jedi2 object.
    * If the names are the same and the force values are the same, the two
    * are considered the same.
    * @params Jedi2 object.
    * @returns <code>boolean</code> true if the objects are the same; false
    * otherwise.
    */

   public boolean compareTo(Jedi2 chosen)  {

      boolean same = true;
      if (!this.getName().equals(chosen.getName()))   // check the names
	 same = false;
      if (this.getForce() != chosen.getForce())	      // check the force values
	 same = false;

      return same;

      }  // end compareTo
	 
}  // end Jedi2 class


