June 2006
Intermediate to advanced
1344 pages
42h 52m
English
In Section 4.5, we introduced properties whose Set accessors allow clients of a class to modify the value of a Private instance variable. In Fig. 4.7, class GradeBook defines property CourseName’s Set accessor to assign the value received in its parameter value to instance variable courseNameValue (line 14). This CourseName property does not ensure that courseNameValue contains valid data. In this section, we enhance our property to include data validation in its Set accessor. Property CourseName (Fig. 4.12) does not ensure that the course name adheres to any particular format or follows any other rules regarding what a “valid” course name is. Suppose that a university can display student ...
Read now
Unlock full access