/**
 * TestJedi.java -- this is an application/main class that serves as a tester 
 * for our Jedi.java program.
 * It has been created to explain the "pass-by-value" and "pass-by-object" 
 * concepts. Please run and understand the following clearly.
 *
 * CSCE 155 Fall 2005
 * @author Leen-Kiat Soh
 * @version 1.0
 */

class TestJedi  {

   /**
    * This main method allows TestJedi to be invoked as an application. It 
    * expects no arguments.  It runs two tests, to show (1) how changes made 
    * to a parameter within a method do not change the argument, and (2) how 
    * changes made to an object parameter within a method do change the 
    * object 'permanently'.
    */

   public static void main(String[] args)  {


      Jedi padawan = new Jedi();
      System.out.println("A padawan has been created");

      /*
      Jedi yoda = new Jedi(1000);
      System.out.println("Yoda has been created");
      */

      System.out.println("I am going to print padawan's information!");
      padawan.printInfo();

      /*
      // -----------------------------------------------------
      // first test: pass-by-value
      // Questions: what is x? what is y?  why?
      // -----------------------------------------------------
      
      Jedi apprentice1 = new Jedi();
      int x = 6;
      int y = 7;
      apprentice1.doSomething(x);
      apprentice1.doSomething(y);

      System.out.println("x = " + x);
      System.out.println("y = " + y);

      int y1 = apprentice1.doSomethingAgain(x);
      int x1 = apprentice1.doSomethingAgain(y);
      System.out.println("x = " + x);
      System.out.println("y = " + y);
      */

      
      // -----------------------------------------------------
      // second test: "pass-by-object"
      // Questions: what is a1's force? what is a2's force?  why?
      // -----------------------------------------------------
      Jedi a1 = new Jedi(5);
      Jedi a2 = new Jedi(10);
      System.out.println("a1's = " + a1.getForce());
      System.out.println("a2's = " + a2.getForce());

      a1.acceptPupil(a2);
      System.out.println("a1's = " + a1.getForce());
      System.out.println("a2's = " + a2.getForce());

      /*
      a2.acceptPupil(a1);
      System.out.println("a1's = " + a1.getForce());
      System.out.println("a2's = " + a2.getForce());


      String someName = "MaceWindu";
      Jedi a1 = new Jedi(5);
      a1.setName(someName);
      System.out.println("a1's = " + a1.getName());
      System.out.println("someName = " + someName);
      */

   }

}  // end TestJedi class


