# Code Samples

The following examples are used to illustrate this topic.

  1. Salutation - This adaptation of the classic "Hello World" program illustrates instance methods. This example includes and introduces the concept of a "driver" and the idea of creating (instantiating) an object based on a class.
  2. Person - This simple class illustrates and introduces the idea of fields (member variables) of a class. This example includes and introduces the idea of a driver. The driver also illustrates how a single class can be used to instantiate multiple, distinct objects.
  3. Account - This simple class also illustrates fields. This example includes a driver.
  4. Comments - This class continues the illustration of the kinds of comments allowed in the programming language. This class builds on the previous example by showing comments for fields as well as methods.
  5. Student - This class introduces a slightly more complex class by offering more fields. This example includes two drivers. By using two drivers, this illustrates that separate "programs" can share/use the same class definition.
    a. The first driver is a simple "test driver" to ensure that the class is "working". This introduces the student to the idea that it is necessary to "test" or prove that the code we are creating is valid.
    b. The second driver illustrates how the a single class can act as the basis for creating many distinct objects.
  6. Employee + Company - These are other classes similar to the Person and Student classes. These classes, however, "share" a driver, illustrating the fact that any given "program" typically uses more than one class. In addition, this driver introduces the ToString() and Parse() methods of the DateTime class.
Last updated on: 9/21/2019, 11:09:56 PM