Give the definitions of three accessor methods that you can use instead of the single accessor method getFirst within the definition of the class PetPair in Listing 6.18. One method will return the pet’s name, one will return the pet’s age, and one will return the pet’s weight. These new accessor methods will not produce the problem described in this section. They will return all of the data in an object of the class PetPair, but will not return any object whose mutator methods can change its state.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here