/**
 * Super.java works with Sub.java and TestSuperSub.java to demonstrate
 * superclass-subclass's data members and methods' visibility/access.
 *
 * 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 Super {

   public int x;                
   protected int y;
   private int z;

   public Super()  {

      x = 10;
      y = 20;
      z = 30;

   }

   public void methodA(Super anotherSuper, Sub sub)  {

      int i;

      // which of the following is legal?
      // the following statements are legal since anotherSuper is an intance of
      // class Super which is the class defined here.

      i = anotherSuper.x;
      i = anotherSuper.y;
      i = anotherSuper.z;

      // which of the following is legal?

      i = sub.a;
      i = sub.b;         // this is legal since Super & Sub use same package
      i = sub.c;         // this is illegal since 'c' is private

      // which of the following is legal?

      i = sub.x;
      i = sub.y;         // this is legal since Super & Sub use same package
      i = sub.z;         // this is illegal since 'z' is private

   }

}



