/**
 * Sub.java works with Super.java and TestSuperSub.java to demonstrate
 * superclass-subclass's data members and methods' visibility/access.
 * Sub.java extends Super.java
 *
 * Note: Since Super.java and Sub.java do not explicitly name the packages that
 * they belong to, that means they belong to the "unnamed" package; thus
 * essentially, they belong to the same package.
 * 
 * CSCE 155 Fall 2005
 * 
 * @author Leen-Kiat Soh
 * @version 1
 *
 */

class Sub extends Super {

   public int a;
   protected int b;
   private int c;

   public Sub()  {

      a = 100;
      b = 200;
      c = 300;

   }

   public void methodA(Sub anotherSub, Super mySuper)  {

      int i;

      // which of the following is valid?
      // Since anotherSub is an instance of Sub, and since this methodA is
      // within the class definition of Sub, then all data members of the
      // instance anotherSub are accessible/visible here.

      i = anotherSub.a;
      i = anotherSub.b;
      i = anotherSub.c;

      // which of the following is valid?

      // Since anotherSub is an instance of Sub, and since this methodA is
      // within the class definition of Sub, then all data members of the
      // instance anotherSub are accessible/visible here.  This applies to all
      // the inherited data members too.  Except for the private data member
      // 'z'.
      
      i = anotherSub.x;         
      i = anotherSub.y;
      i = anotherSub.z;         // this is illegal since 'z' is private

      // which of the following is valid?

      i = mySuper.x;
      i = mySuper.y;
      i = mySuper.z;            // this is illegal since 'z' is private

   }

}


