Source of PetPair.java


  1: //PetPair.java
  2: 
  3: /**
  4:  * Class whose privacy can be breached.
  5:  */
  6: public class PetPair
  7: {
  8:     private Pet first, second;
  9: 
 10:     public PetPair
 11:     (
 12:         Pet firstPet,
 13:         Pet secondPet
 14:     )
 15:     {
 16:         first = firstPet;
 17:         second = secondPet;
 18:     }
 19: 
 20:     public Pet getFirst()
 21:     {
 22:         return first;
 23:     }
 24: 
 25:     public Pet getSecond()
 26:     {
 27:         return second;
 28:     }
 29: 
 30:     public void writeOutput()
 31:     {
 32:         System.out.println("First pet in the pair:");
 33:         first.writeOutput();
 34:         System.out.println("\nSecond pet in the pair:");
 35:         second.writeOutput();
 36:     }
 37: }