You just learned how to define getter and setter methods to a class definition, and also how use them in a program. Put your newfound knowledge to use.
- get meaningful reps defining getter and setter methods within a class definition
- user setter methods to set attributes of an object
- user getter methods to retieve attributes of an object
- Within your
Userclass definition, write a getter and setter method for anageattribute. - Test your new getter and setter method for age, setting an age to a user and retrieving the value.
- Great, now write a getter and setter method for an
genderattribute. - Test your new getter and setter method for gender, setting a gender to a user and retrieving the value.