How to create set and get methods in a class