

// Burton Rosenberg
// Wed Feb 11 11:22:28 EST 1998
// MySecondObject.java

/*
   EXAMPLE RUN:

   appomattox> javac MySecondObject.java
   appomattox> java MySecondObject
   3
   5
   appomattox> 
*/

class MySecondObject
{

    public static void main( String [] argv )
    {
       TheObject o1, o2 ;
       o1 = new TheObject() ;
       o2 = new TheObject() ;
    
       o1.enterValue(1) ;
       o1.enterValue(2) ;
       o1.enterValue(6) ;

       o2.enterValue(4) ;
       o2.enterValue(6) ;

       o1.printAverage() ;
       o2.printAverage() ;
    }


}

class TheObject 
{

   int theHiddenValue = 0 ;
   int count = 0 ;

   void printValue() 
   {
      System.out.println(theHiddenValue) ;
   }

   void setValue(int newValue)
   {
      theHiddenValue = newValue ;
      count = 0 ;
   }

   void enterValue(int amount)
   {
      theHiddenValue = theHiddenValue + amount ;
      count = count + 1 ;
   }

   void printAverage()
   {
      if ( count != 0 )
      {
         System.out.println( theHiddenValue/count ) ;
      }
   }

}

