1.3 This exercise presents an alternative to having protected fields. Modify the FullTimeEmployee class as follows: Change the visibility of the name and grossPay fields from protected to private, and develop public methods to get and set the values of those fields. A method that alters a field in an object is called a mutator, and a method that returns a copy of a field is called an accessor. Here are the method specifications corresponding to the name field: /** * Returns this FullTimeEmployee object's name. * * @return a (reference to a) copy of this FullTimeEmployee object's * name. * */ public String getName () /** * Sets this FullTimeEmployee object's name to a specifed string. * * @param nameIn - the String object whose value is assigned to this * FullTimeEmployee object's name. * */ public void setName (String nameIn) | |
| View Solution | |
| << Back | Next >> |