/**
  * This class is both a basic and application class.  It is designed to
  * investigate the constructor methods, the getter and setter methods, and
  * the use of "this" pointer, and also the notion of "overloading".
  * JDEP 183H Fall 2008
  *
  * @author Leen-Kiat Soh
  * @version 1.0
  */

class ClassA {

   private int foobar;
   private double wombat;

   /**
    * This is the first constructor of the ClassA class.
    * It expects an integer argument.
    */

   public ClassA (int x)  {
      foobar = x;
      wombat = 50.00;
      System.out.println("I am first constructor");
   }

   /**
    * This is the second constructor of the ClassA class.
    * It expects no argument.
    */

   public ClassA ()  {

      // foobar = 5;
      // wombat = 50.00;
      this(5);
      System.out.println("I am second constructor");

   }

   /**
    * This is the third constructor of the ClassA class.
    * It expects a double argument.
    */
   public ClassA (double x)  {

      foobar = (int) x;
      wombat = 50.00;
      System.out.println("I am third constructor");
   }


   /**
    * This is the setter method for variable foobar
    * // Watch out for the local variable!!
    * This method is not correctly designed.
    */

   public void setFoobar (int newFoobar)  {

      int foobar;       // local variable; experiment with this; understand this well.
                        // the correct way of implemneting a setter is to take out this
                        // line
      foobar = newFoobar;

      // this.foobar = foobar;   // experiment with this; understand this well.
   }

   /**
    * This is the getter method for variable wombat
    * Watch out for the local variable!!
    * This method is not correctly designed.
    */

   public double getWombat () {

      double wombat = 3.0;
      return wombat;
      }

   /**
    * This is the setter method for variable wombat
    * This method is correctly designed.
    */

   public void setWombat (double okay)  {
      wombat = okay;
      }

   /**
    * This method returns the product of wombat and foobar.  It returns a
    * double.
    */

   public double compute() {
      double x; // to store intermediate result on energy
      double y; // to store intermediate result on aggressiveness

      x = wombat*2.0*Math.sqrt(wombat)*Math.cos(foobar);
      y = foobar*2.0*Math.sqrt(foobar)*Math.sin(wombat);

      return (x*y);

      }

   /**
    * This method prints the information on foobar and wombat of the instance.
    */

   public void printInfo()  {
      System.out.println("foobar = " + foobar + " and wombat = " + wombat);
      }


   public void printInfo(String gibberish)  {
      System.out.println(gibberish + gibberish + gibberish);
      System.out.println("foobar = " + foobar + " and wombat = " + wombat);
      }


   /**
    * This method is the main method.  It instantiates a ClassA object called
    * 'baba' and manipulates the object.
    */

   public static void main (String[] args)  {
     
      ClassA baba = new ClassA(3.15);
      baba.printInfo();

      baba.setFoobar(10);
      baba.printInfo();

      /*
      baba.setWombat(7.0*baba.getWombat());
      baba.printInfo();

      baba = new ClassA(6);
      baba.printInfo();
      baba.setWombat(9.0);
      baba.printInfo();
      baba.setFoobar((int) baba.getWombat());
      baba.printInfo();
      baba.setWombat(baba.compute());
      baba.printInfo();
      */
      }
   }







