3.3. Behavior/Operations/Methods

Now let's revisit the same two types of objects—a student and a course—and talk about these objects' respective behaviors. A student's behaviors (relevant to academic matters, that is!) might include these:

  • Enrolling in a course

  • Dropping a course

  • Choosing a major field of study

  • Selecting a faculty advisor

  • Telling you his or her GPA

  • Telling you whether or not he or she has taken a particular course; if so, when the course was taken, which professor taught it, and what grade the student received

It's a bit harder to think of an inanimate, conceptual object such as a course as having behaviors, but if we were to imagine a course to be a living thing, we can imagine that a course's behaviors might include the following: ...

Get Beginning C# 2008 Objects: From Concept to Code now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.