Source of CadetClass.java


  1: 
  2: /**
  3:  Example of a class that does NOT correctly
  4:  hide its private instance variable.
  5: */
  6: public class CadetClass
  7: {
  8:     private PetRecord pet;
  9: 
 10:     public CadetClass( )
 11:     {
 12:         pet =
 13:             new PetRecord("Faithful Guard Dog", 5, 75);
 14:     }
 15: 
 16:     public void writeOutput( )
 17:     {
 18:         System.out.println("Here's the pet:");
 19:         pet.writeOutput( );
 20:     }
 21: 
 22:     public PetRecord getPet( )
 23:     {
 24:         return pet;
 25:     }
 26: }